Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
759e37f3
Commit
759e37f3
authored
Dec 14, 2016
by
Mike Greiling
Committed by
Alfredo Sumaran
Dec 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reduce common code even further to satisfy rake flay
parent
4e3b9e03
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+25
-23
No files found.
app/helpers/commits_helper.rb
View file @
759e37f3
...
@@ -128,31 +128,11 @@ module CommitsHelper
...
@@ -128,31 +128,11 @@ module CommitsHelper
end
end
def
revert_commit_link
(
commit
,
continue_to_path
,
btn_class:
nil
,
has_tooltip:
true
)
def
revert_commit_link
(
commit
,
continue_to_path
,
btn_class:
nil
,
has_tooltip:
true
)
return
unless
current_user
commit_action_link
(
'revert'
,
commit
,
continue_to_path
,
btn_class:
btn_class
,
has_tooltip:
has_tooltip
)
tooltip
=
"Revert this
#{
commit
.
change_type_title
(
current_user
)
}
in a new merge request"
if
has_tooltip
btn_class
=
"btn btn-
#{
btn_class
}
"
unless
btn_class
.
nil?
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
)
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
end
def
cherry_pick_commit_link
(
commit
,
continue_to_path
,
btn_class:
nil
,
has_tooltip:
true
)
def
cherry_pick_commit_link
(
commit
,
continue_to_path
,
btn_class:
nil
,
has_tooltip:
true
)
return
unless
current_user
commit_action_link
(
'cherry-pick'
,
commit
,
continue_to_path
,
btn_class:
btn_class
,
has_tooltip:
has_tooltip
)
tooltip
=
"Cherry-pick this
#{
commit
.
change_type_title
(
current_user
)
}
in a new merge request"
if
has_tooltip
btn_class
=
"btn btn-
#{
btn_class
}
"
unless
btn_class
.
nil?
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
)
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
end
protected
protected
...
@@ -192,6 +172,28 @@ module CommitsHelper
...
@@ -192,6 +172,28 @@ module CommitsHelper
end
end
end
end
def
commit_action_link
(
action
,
commit
,
continue_to_path
,
btn_class:
nil
,
has_tooltip:
true
)
return
unless
current_user
tooltip
=
"
#{
action
.
capitalize
}
this
#{
commit
.
change_type_title
(
current_user
)
}
in a new merge request"
if
has_tooltip
btn_class
=
"btn btn-
#{
btn_class
}
"
unless
btn_class
.
nil?
if
can_collaborate_with_project?
link_to
action
.
capitalize
,
"#modal-
#{
action
}
-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
#{
action
}
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
)
link_to
action
.
capitalize
,
fork_path
,
class:
btn_class
,
method: :post
,
'data-toggle'
=>
'tooltip'
,
'data-container'
=>
'body'
,
title:
(
tooltip
if
has_tooltip
)
end
end
def
fork_path_url
(
continue_to_path
,
message:
nil
)
def
fork_path_url
(
continue_to_path
,
message:
nil
)
notice
=
edit_in_new_fork_notice
notice
=
edit_in_new_fork_notice
notice
<<
"
#{
message
}
"
unless
message
.
nil?
notice
<<
"
#{
message
}
"
unless
message
.
nil?
...
@@ -201,7 +203,7 @@ module CommitsHelper
...
@@ -201,7 +203,7 @@ module CommitsHelper
notice:
notice
,
notice:
notice
,
notice_now:
edit_in_new_fork_notice_now
notice_now:
edit_in_new_fork_notice_now
}
}
fork_path
=
namespace_project_forks_path
(
@project
.
namespace
,
@project
,
namespace_project_forks_path
(
@project
.
namespace
,
@project
,
namespace_key:
current_user
.
namespace
.
id
,
namespace_key:
current_user
.
namespace
.
id
,
continue:
continue_params
)
continue:
continue_params
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment