Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e01c692a
Commit
e01c692a
authored
Jan 05, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tag with git hooks
parent
99ac0935
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
app/models/repository.rb
app/models/repository.rb
+11
-8
app/services/delete_tag_service.rb
app/services/delete_tag_service.rb
+1
-1
app/services/git_operation_service.rb
app/services/git_operation_service.rb
+11
-1
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+3
-2
No files found.
app/models/repository.rb
View file @
e01c692a
...
@@ -196,16 +196,14 @@ class Repository
...
@@ -196,16 +196,14 @@ class Repository
true
true
end
end
# TODO: why we don't pass user here?
def
rm_tag
(
user
,
tag_name
)
def
rm_tag
(
tag_name
)
before_remove_tag
before_remove_tag
tag
=
find_tag
(
tag_name
)
begin
GitOperationService
.
new
(
user
,
self
).
rm_tag
(
tag
)
rugged
.
tags
.
delete
(
tag_name
)
true
after_remove_tag
rescue
Rugged
::
ReferenceError
true
false
end
end
end
def
ref_names
def
ref_names
...
@@ -401,6 +399,11 @@ class Repository
...
@@ -401,6 +399,11 @@ class Repository
repository_event
(
:remove_tag
)
repository_event
(
:remove_tag
)
end
end
# Runs code after removing a tag.
def
after_remove_tag
expire_tags_cache
end
def
before_import
def
before_import
expire_content_cache
expire_content_cache
end
end
...
...
app/services/delete_tag_service.rb
View file @
e01c692a
...
@@ -7,7 +7,7 @@ class DeleteTagService < BaseService
...
@@ -7,7 +7,7 @@ class DeleteTagService < BaseService
return
error
(
'No such tag'
,
404
)
return
error
(
'No such tag'
,
404
)
end
end
if
repository
.
rm_tag
(
tag_name
)
if
repository
.
rm_tag
(
current_user
,
tag_name
)
release
=
project
.
releases
.
find_by
(
tag:
tag_name
)
release
=
project
.
releases
.
find_by
(
tag:
tag_name
)
release
.
destroy
if
release
release
.
destroy
if
release
...
...
app/services/git_operation_service.rb
View file @
e01c692a
...
@@ -15,7 +15,7 @@ class GitOperationService
...
@@ -15,7 +15,7 @@ class GitOperationService
def
rm_branch
(
branch
)
def
rm_branch
(
branch
)
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch
.
name
ref
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
branch
.
name
oldrev
=
branch
.
dereferenced_target
.
id
oldrev
=
branch
.
target
newrev
=
Gitlab
::
Git
::
BLANK_SHA
newrev
=
Gitlab
::
Git
::
BLANK_SHA
update_ref_in_hooks
(
ref
,
newrev
,
oldrev
)
update_ref_in_hooks
(
ref
,
newrev
,
oldrev
)
...
@@ -36,6 +36,16 @@ class GitOperationService
...
@@ -36,6 +36,16 @@ class GitOperationService
end
end
end
end
def
rm_tag
(
tag
)
ref
=
Gitlab
::
Git
::
TAG_REF_PREFIX
+
tag
.
name
oldrev
=
tag
.
target
newrev
=
Gitlab
::
Git
::
BLANK_SHA
update_ref_in_hooks
(
ref
,
newrev
,
oldrev
)
do
repository
.
rugged
.
tags
.
delete
(
tag_name
)
end
end
# Whenever `source_branch_name` is passed, if `branch_name` doesn't exist,
# Whenever `source_branch_name` is passed, if `branch_name` doesn't exist,
# it would be created from `source_branch_name`.
# it would be created from `source_branch_name`.
# If `source_project` is passed, and the branch doesn't exist,
# If `source_project` is passed, and the branch doesn't exist,
...
...
spec/models/repository_spec.rb
View file @
e01c692a
...
@@ -1419,9 +1419,10 @@ describe Repository, models: true do
...
@@ -1419,9 +1419,10 @@ describe Repository, models: true do
describe
'#rm_tag'
do
describe
'#rm_tag'
do
it
'removes a tag'
do
it
'removes a tag'
do
expect
(
repository
).
to
receive
(
:before_remove_tag
)
expect
(
repository
).
to
receive
(
:before_remove_tag
)
expect
(
repository
.
rugged
.
tags
).
to
receive
(
:delete
).
with
(
'v1.1.0'
)
repository
.
rm_tag
(
'v1.1.0'
)
repository
.
rm_tag
(
create
(
:user
),
'v1.1.0'
)
expect
(
repository
.
find_tag
(
'v1.1.0'
)).
to
be_nil
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment