Commit 177025b5 authored by Yorick Peterse's avatar Yorick Peterse

Call the right hooks when removing branches

This ensures that Repository#rm_branch calls
before_remove_branch/after_remove_branch instead of just 1 random cache
expiration method.
parent cb5a5ba0
......@@ -144,7 +144,7 @@ class Repository
end
def rm_branch(user, branch_name)
expire_branches_cache
before_remove_branch
branch = find_branch(branch_name)
oldrev = branch.try(:target)
......@@ -155,7 +155,7 @@ class Repository
rugged.branches.delete(branch_name)
end
expire_branches_cache
after_remove_branch
true
end
......@@ -359,10 +359,16 @@ class Repository
expire_branch_count_cache
end
# Runs code before removing an existing branch.
def before_remove_branch
expire_branches_cache
end
# Runs code after an existing branch has been removed.
def after_remove_branch
expire_has_visible_content_cache
expire_branch_count_cache
expire_branches_cache
end
def method_missing(m, *args, &block)
......
......@@ -648,4 +648,15 @@ describe Repository, models: true do
repository.expire_tag_count_cache
end
end
describe '#rm_branch' do
let(:user) { create(:user) }
it 'removes a branch' do
expect(repository).to receive(:before_remove_branch)
expect(repository).to receive(:after_remove_branch)
repository.rm_branch(user, 'feature')
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