Call after_create_branch in Repository#add_branch
This ensures the right caches are flushed when adding a branch via the UI, instead of only flushing this one random cache.
This commit is contained in:
parent
4ec035b488
commit
590e1b4b21
2 changed files with 8 additions and 1 deletions
|
@ -133,7 +133,7 @@ class Repository
|
||||||
rugged.branches.create(branch_name, target)
|
rugged.branches.create(branch_name, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
expire_branches_cache
|
after_create_branch
|
||||||
find_branch(branch_name)
|
find_branch(branch_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -356,6 +356,7 @@ class Repository
|
||||||
|
|
||||||
# Runs code after a new branch has been created.
|
# Runs code after a new branch has been created.
|
||||||
def after_create_branch
|
def after_create_branch
|
||||||
|
expire_branches_cache
|
||||||
expire_has_visible_content_cache
|
expire_has_visible_content_cache
|
||||||
expire_branch_count_cache
|
expire_branch_count_cache
|
||||||
end
|
end
|
||||||
|
|
|
@ -148,6 +148,12 @@ describe Repository, models: true do
|
||||||
|
|
||||||
expect(branch.name).to eq('new_feature')
|
expect(branch.name).to eq('new_feature')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'calls the after_create_branch hook' do
|
||||||
|
expect(repository).to receive(:after_create_branch)
|
||||||
|
|
||||||
|
repository.add_branch(user, 'new_feature', 'master')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when pre hooks failed' do
|
context 'when pre hooks failed' do
|
||||||
|
|
Loading…
Reference in a new issue