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
)
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
tooltip = "Revert this #{revert_commit_type(commit)} in a new merge request"
if can_collaborate_with_project?
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
else
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.',
......@@ -140,7 +142,15 @@ module CommitsHelper
namespace_key: current_user.namespace.id,
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
......
......@@ -601,7 +601,6 @@ class Repository
def merge(user, source_sha, target_branch, options = {})
our_commit = rugged.branches[target_branch].target
their_commit = rugged.lookup(source_sha)
merge_commit_sha = nil
raise "Invalid merge target" if our_commit.nil?
raise "Invalid merge source" if their_commit.nil?
......@@ -616,10 +615,8 @@ class Repository
update_ref: ref
)
merge_commit_sha = Rugged::Commit.create(rugged, actual_options)
Rugged::Commit.create(rugged, actual_options)
end
merge_commit_sha
end
def revert(user, commit, base_branch, target_branch = nil)
......@@ -762,6 +759,8 @@ class Repository
end
end
end
newrev
end
end
......
......@@ -17,7 +17,7 @@
= icon('files-o')
Browse Files
- 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
%p
......
......@@ -6,8 +6,8 @@
- if @merge_request.merge_event
by #{link_to_member(@project, @merge_request.merge_event.author, avatar: true)}
#{time_ago_with_tooltip(@merge_request.merge_event.created_at)}
- unless @merge_request.has_been_reverted?(current_user)
= revert_commit_link(namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm')
- if @merge_request.merge_commit && !@merge_request.has_been_reverted?(current_user)
= revert_commit_link(@merge_request.merge_commit, namespace_project_merge_request_path(@project.namespace, @project, @merge_request), btn_class: 'sm')
%div
- if !@merge_request.source_branch_exists? || (params[:delete_source] == 'true')
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