Commit 72e536b5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Detect rebase state based on rebase directory

parent 7c12a8d4
...@@ -506,4 +506,12 @@ class MergeRequest < ActiveRecord::Base ...@@ -506,4 +506,12 @@ class MergeRequest < ActiveRecord::Base
def ff_merge_possible? def ff_merge_possible?
target_sha == source_sha_parent target_sha == source_sha_parent
end end
def rebase_dir_path
Rails.root.join('tmp', 'rebase', source_project.id.to_s, id.to_s).to_s
end
def rebase_in_progress?
File.exist?(rebase_dir_path)
end
end end
...@@ -52,6 +52,7 @@ module MergeRequests ...@@ -52,6 +52,7 @@ module MergeRequests
true true
ensure ensure
clean_dir
Gitlab::ShellEnv.reset_env Gitlab::ShellEnv.reset_env
end end
...@@ -64,11 +65,15 @@ module MergeRequests ...@@ -64,11 +65,15 @@ module MergeRequests
end end
def tree_path def tree_path
@tree_path ||= Rails.root.join('tmp', 'rebase', source_project.id.to_s, SecureRandom.hex).to_s @tree_path ||= merge_request.rebase_dir_path
end end
def log(message) def log(message)
Gitlab::GitLogger.error(message) Gitlab::GitLogger.error(message)
end end
def clean_dir
FileUtils.rm_rf(tree_path) if File.exist?(tree_path)
end
end end
end end
...@@ -14,9 +14,12 @@ ...@@ -14,9 +14,12 @@
= hidden_field_tag :authenticity_token, form_authenticity_token = hidden_field_tag :authenticity_token, form_authenticity_token
.accept-merge-holder.clearfix.js-toggle-container .accept-merge-holder.clearfix.js-toggle-container
- if @merge_request.target_project.merge_requests_rebase_enabled && can_rebase?(@merge_request.target_project, @merge_request.target_branch) - if @merge_request.target_project.merge_requests_rebase_enabled && can_rebase?(@merge_request.target_project, @merge_request.target_branch)
.accept-action - if @merge_request.rebase_in_progress?
= f.button class: "btn btn-reopen rebase-mr" do %h4 Rebase in progress... It can take a while. Reload at will.
Rebase from #{@merge_request.target_branch} - else
.accept-action
= f.button class: "btn btn-reopen rebase-mr" do
Rebase from #{@merge_request.target_branch}
.accept-control .accept-control
Fast-forward merge is not possible. Branch must be rebased first Fast-forward merge is not possible. Branch must be rebased first
......
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