Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-18 16:16:46 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-08-18 16:16:46 +0300
commit798f2fe19f4fb90a99d77f3d77011cdba5a73046 (patch)
tree5e855c4b52322ed250a7f658f4e2e0379dbb5194
parent2a704396fb434c56a1ca2c41d65fd22a8b9a6d9c (diff)
parent6e808fc222dde420749fcf9ed006cfb6983e4b70 (diff)
Merge branch 'mr-source-branch-clear-cache' into 'master'
Clear cache to prevent listing deleted branches after MR removes source branch Closes #2272 See merge request !1160
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/repository.rb4
-rw-r--r--lib/gitlab/satellite/merge_action.rb1
-rw-r--r--spec/lib/gitlab/satellite/merge_action_spec.rb14
4 files changed, 20 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c7511bd3245..9ebf918371f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
- Fix redirection after sign in when using auto_sign_in_with_provider
- Upgrade gitlab_git to 7.2.14 to ignore CRLFs in .gitmodules (Stan Hu)
+ - 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)
- Fix bug where backslashes in inline diffs could be dropped (Stan Hu)
- Disable turbolinks when linking to Bitbucket import status (Stan Hu)
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 3bba3ca888a..24c32d90051 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -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] ||= {}
diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb
index f9bf286697e..52e8130956c 100644
--- a/lib/gitlab/satellite/merge_action.rb
+++ b/lib/gitlab/satellite/merge_action.rb
@@ -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
diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb
index 9b1c9a34e29..e977261c726 100644
--- a/spec/lib/gitlab/satellite/merge_action_spec.rb
+++ b/spec/lib/gitlab/satellite/merge_action_spec.rb
@@ -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