Commit 6e808fc2 authored by Stan Hu's avatar Stan Hu

Clear cache to prevent listing deleted branches after MR removes source branch

Closes #2272
parent f6f58cfb
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
- Clear cache to prevent listing deleted branches after MR removes source branch (Stan Hu)
- Provide more feedback what went wrong if HipChat service failed test (Stan Hu)
- Disable turbolinks when linking to Bitbucket import status (Stan Hu)
- Fix broken code import and display error messages if something went wrong with creating project (Stan Hu)
......
......@@ -148,6 +148,10 @@ class Repository
@lookup_cache ||= {}
end
def expire_branch_names
cache.expire(:branch_names)
end
def method_missing(m, *args, &block)
if m == :lookup && !block_given?
lookup_cache[m] ||= {}
......
......@@ -36,6 +36,7 @@ module Gitlab
if merge_request.remove_source_branch?
# will raise CommandFailed when push fails
merge_repo.git.push(default_options, :origin, ":#{merge_request.source_branch}")
merge_request.source_project.repository.expire_branch_names
end
# merge, push and branch removal successful
true
......
......@@ -101,4 +101,18 @@ describe 'Gitlab::Satellite::MergeAction' do
end
end
end
describe '#merge!' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: "markdown", should_remove_source_branch: true) }
let(:merge_action) { Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request) }
it 'clears cache of source repo after removing source branch' do
project.repository.expire_branch_names
expect(project.repository.branch_names).to include('markdown')
merge_action.merge!
expect(project.repository.branch_names).not_to include('markdown')
end
end
end
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