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:
authorMike Greiling <mike@pixelcog.com>2016-12-13 18:49:05 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2016-12-21 10:36:05 +0300
commit26a80149b0381e678ac6b4f13340e81055be3406 (patch)
tree00259104eb06b8b3b9f0dee1f14fde92af55c32d /app/helpers/commits_helper.rb
parent35adeee5148eddebc003abcd690ad01a50219bde (diff)
factor out common code to satisfy rake flay
Diffstat (limited to 'app/helpers/commits_helper.rb')
-rw-r--r--app/helpers/commits_helper.rb34
1 files changed, 16 insertions, 18 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 4d61833d624..e7d78cc422e 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -136,15 +136,7 @@ module CommitsHelper
if can_collaborate_with_project?
link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}"
elsif can?(current_user, :fork_project, @project)
- continue_params = {
- to: continue_to_path,
- notice: edit_in_new_fork_notice + ' Try to revert this commit again.',
- notice_now: edit_in_new_fork_notice_now
- }
- fork_path = namespace_project_forks_path(@project.namespace, @project,
- namespace_key: current_user.namespace.id,
- continue: continue_params)
-
+ fork_path = fork_path_url(continue_to_path, message: 'Try to revert this commit again.')
link_to 'Revert', fork_path, class: btn_class, method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip)
end
end
@@ -158,15 +150,7 @@ module CommitsHelper
if can_collaborate_with_project?
link_to 'Cherry-pick', '#modal-cherry-pick-commit', 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}"
elsif can?(current_user, :fork_project, @project)
- continue_params = {
- to: continue_to_path,
- notice: edit_in_new_fork_notice + ' Try to cherry-pick this commit again.',
- notice_now: edit_in_new_fork_notice_now
- }
- fork_path = namespace_project_forks_path(@project.namespace, @project,
- namespace_key: current_user.namespace.id,
- continue: continue_params)
-
+ fork_path = fork_path_url(continue_to_path, message: 'Try to cherry-pick this commit again.')
link_to 'Cherry-pick', fork_path, class: btn_class, method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip)
end
end
@@ -208,6 +192,20 @@ module CommitsHelper
end
end
+ def fork_path_url(continue_to_path, message: nil)
+ notice = edit_in_new_fork_notice
+ notice << " #{message}" unless message.nil?
+
+ continue_params = {
+ to: continue_to_path,
+ notice: notice,
+ notice_now: edit_in_new_fork_notice_now
+ }
+ fork_path = namespace_project_forks_path(@project.namespace, @project,
+ namespace_key: current_user.namespace.id,
+ continue: continue_params)
+ end
+
def view_file_btn(commit_sha, diff_new_path, project)
link_to(
namespace_project_blob_path(project.namespace, project,