Commit 8b7bf2a0 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rugged-delete-tag' into 'master'

Delete tags via rugged

Improve the performance by directly using rugged instead of shelling out to a git operation.

See merge request !3748
parents 2ac0050b 3c704c33
No related merge requests found
......@@ -67,6 +67,7 @@ v 8.7.0 (unreleased)
- Fix repository cache invalidation issue when project is recreated with an empty repo (Stan Hu)
- Fix: Allow empty recipients list for builds emails service when pushed is added (Frank Groeneveld)
- Improved markdown forms
- Delete tags using Rugged for performance reasons (Robert Schilling)
- Diffs load at the correct point when linking from from number
- Selected diff rows highlight
- Fix emoji catgories in the emoji picker
......
......@@ -169,7 +169,12 @@ class Repository
def rm_tag(tag_name)
before_remove_tag
gitlab_shell.rm_tag(path_with_namespace, tag_name)
begin
rugged.tags.delete(tag_name)
true
rescue Rugged::ReferenceError
false
end
end
def branch_names
......
......@@ -110,19 +110,6 @@ module Gitlab
Gitlab::Utils.system_silent(cmd)
end
# Remove repository tag
#
# path - project path with namespace
# tag_name - tag name to remove
#
# Ex.
# rm_tag("gitlab/gitlab-ci", "v4.0")
#
def rm_tag(path, tag_name)
Gitlab::Utils.system_silent([gitlab_shell_projects_path, 'rm-tag',
"#{path}.git", tag_name])
end
# Gc repository
#
# path - project path with namespace
......
......@@ -770,11 +770,9 @@ describe Repository, models: true do
describe '#rm_tag' do
it 'removes a tag' do
expect(repository).to receive(:before_remove_tag)
expect(repository.rugged.tags).to receive(:delete).with('v1.1.0')
expect_any_instance_of(Gitlab::Shell).to receive(:rm_tag).
with(repository.path_with_namespace, '8.5')
repository.rm_tag('8.5')
repository.rm_tag('v1.1.0')
end
end
......
......@@ -6,21 +6,12 @@ describe DeleteTagService, services: true do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
let(:tag) { double(:tag, name: '8.5', target: 'abc123') }
describe '#execute' do
before do
allow(repository).to receive(:find_tag).and_return(tag)
end
it 'removes the tag' do
expect_any_instance_of(Gitlab::Shell).to receive(:rm_tag).
and_return(true)
expect(repository).to receive(:before_remove_tag)
expect(service).to receive(:success)
service.execute('8.5')
service.execute('v1.1.0')
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