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
def ff_merge_possible?
target_sha == source_sha_parent
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
......@@ -52,6 +52,7 @@ module MergeRequests
true
ensure
clean_dir
Gitlab::ShellEnv.reset_env
end
......@@ -64,11 +65,15 @@ module MergeRequests
end
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
def log(message)
Gitlab::GitLogger.error(message)
end
def clean_dir
FileUtils.rm_rf(tree_path) if File.exist?(tree_path)
end
end
end
......@@ -14,9 +14,12 @@
= hidden_field_tag :authenticity_token, form_authenticity_token
.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)
.accept-action
= f.button class: "btn btn-reopen rebase-mr" do
Rebase from #{@merge_request.target_branch}
- if @merge_request.rebase_in_progress?
%h4 Rebase in progress... It can take a while. Reload at will.
- else
.accept-action
= f.button class: "btn btn-reopen rebase-mr" do
Rebase from #{@merge_request.target_branch}
.accept-control
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