Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2016-02-04 02:28:40 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-02-19 21:14:50 +0300
commit806139936898726b32c4fe216ac3a9f4419ce91e (patch)
tree7329f75325b00fe74999ed1d5d384c9ff01038d3 /app/controllers/projects/commit_controller.rb
parent34e26b8212954dba32165c39b63858658b82c0f0 (diff)
Add RevertService class with basic logic to revert commit
Diffstat (limited to 'app/controllers/projects/commit_controller.rb')
-rw-r--r--app/controllers/projects/commit_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 96cb9761f3b..d996b0f4ca7 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -11,6 +11,7 @@ class Projects::CommitController < Projects::ApplicationController
before_action :authorize_read_commit_status!, only: [:builds]
before_action :commit
before_action :define_show_vars, only: [:show, :builds]
+ before_action :assign_revert_commit_vars, only: [:revert]
before_action :authorize_edit_tree!, only: [:revert]
def show
@@ -59,7 +60,11 @@ class Projects::CommitController < Projects::ApplicationController
end
def revert
+ # return render_404 unless @commit_params.values.all?
+ create_commit(Commits::RevertService, success_notice: "The commit has been successfully reverted.",
+ success_path: namespace_project_commits_path(@project.namespace, @project, @target_branch),
+ failure_path: namespace_project_commit_path(@project.namespace, @project, params[:id]))
end
private
@@ -86,4 +91,12 @@ class Projects::CommitController < Projects::ApplicationController
@statuses = ci_commit.statuses if ci_commit
end
+
+ def assign_revert_commit_vars
+ @target_branch = params[:target_branch]
+
+ @commit_params = {
+ revert_commit_id: params[:id],
+ }
+ end
end