Commit d958d027 authored by Rubén Dávila's avatar Rubén Dávila Committed by Robert Speicher

Make #commit_with_hooks return the new obj id plus some other fixes.

parent d34733ef
...@@ -123,14 +123,16 @@ module CommitsHelper ...@@ -123,14 +123,16 @@ module CommitsHelper
) )
end end
def revert_commit_link(continue_to_path, btn_class: nil) def revert_commit_link(commit, continue_to_path, btn_class: nil)
return unless current_user return unless current_user
tooltip = "Revert this #{revert_commit_type(commit)} in a new merge request"
if can_collaborate_with_project? if can_collaborate_with_project?
content_tag :span, 'data-toggle' => 'modal', 'data-target' => '#modal-revert-commit' do content_tag :span, 'data-toggle' => 'modal', 'data-target' => '#modal-revert-commit' do
link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'tooltip', 'data-original-title' => 'Create merge request to revert commit', class: "btn btn-close btn-#{btn_class}" link_to 'Revert', '#modal-revert-commit', 'data-toggle' => 'tooltip', 'data-original-title' => tooltip, class: "btn btn-close btn-#{btn_class}"
end end
else elsif can?(current_user, :fork_project, @project)
continue_params = { continue_params = {
to: continue_to_path, to: continue_to_path,
notice: edit_in_new_fork_notice + ' Try to revert this commit again.', notice: edit_in_new_fork_notice + ' Try to revert this commit again.',
...@@ -140,7 +142,15 @@ module CommitsHelper ...@@ -140,7 +142,15 @@ module CommitsHelper
namespace_key: current_user.namespace.id, namespace_key: current_user.namespace.id,
continue: continue_params) continue: continue_params)
link_to 'Revert', fork_path, class: 'btn btn-grouped btn-close', method: :post, 'data-toggle' => 'tooltip', 'data-original-title' => 'Create merge request to revert commit' link_to 'Revert', fork_path, class: 'btn btn-grouped btn-close', method: :post, 'data-toggle' => 'tooltip', 'data-original-title' => tooltip
end
end
def revert_commit_type(commit)
if commit.merged_merge_request
'merge request'
else
'commit'
end end
end end
......
...@@ -601,7 +601,6 @@ class Repository ...@@ -601,7 +601,6 @@ class Repository
def merge(user, source_sha, target_branch, options = {}) def merge(user, source_sha, target_branch, options = {})
our_commit = rugged.branches[target_branch].target our_commit = rugged.branches[target_branch].target
their_commit = rugged.lookup(source_sha) their_commit = rugged.lookup(source_sha)
merge_commit_sha = nil
raise "Invalid merge target" if our_commit.nil? raise "Invalid merge target" if our_commit.nil?
raise "Invalid merge source" if their_commit.nil? raise "Invalid merge source" if their_commit.nil?
...@@ -616,10 +615,8 @@ class Repository ...@@ -616,10 +615,8 @@ class Repository
update_ref: ref update_ref: ref
) )
merge_commit_sha = Rugged::Commit.create(rugged, actual_options) Rugged::Commit.create(rugged, actual_options)
end end
merge_commit_sha
end end
def revert(user, commit, base_branch, target_branch = nil) def revert(user, commit, base_branch, target_branch = nil)
...@@ -762,6 +759,8 @@ class Repository ...@@ -762,6 +759,8 @@ class Repository
end end
end end
end end
newrev
end end
end end
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
= icon('files-o') = icon('files-o')
Browse Files Browse Files
- unless @commit.has_been_reverted?(current_user) - unless @commit.has_been_reverted?(current_user)
= revert_commit_link(namespace_project_commit_path(@project.namespace, @project, @commit.id)) = revert_commit_link(@commit, namespace_project_commit_path(@project.namespace, @project, @commit.id))
%div %div
%p %p
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
- if @merge_request.merge_event - if @merge_request.merge_event
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)} by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)} #{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
- unless @merge_request.has_been_reverted?(current_user) - if @merge_request.merge_commit && !@merge_request.has_been_reverted?(current_user)
= revert_commit_link(namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm') = revert_commit_link(@merge_request.merge_commit, namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm')
%div %div
- if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true') - if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
The changes were merged into The changes were merged into
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment