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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
678f3ddd
Commit
678f3ddd
authored
Sep 04, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7305 from asedge/annotated_tags
Annotated tags
parents
69d149e0
468b2e8e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
14 deletions
+51
-14
CHANGELOG
CHANGELOG
+1
-0
app/controllers/projects/tags_controller.rb
app/controllers/projects/tags_controller.rb
+2
-1
app/models/repository.rb
app/models/repository.rb
+2
-2
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+6
-2
app/views/projects/tags/new.html.haml
app/views/projects/tags/new.html.haml
+5
-0
doc/api/repositories.md
doc/api/repositories.md
+1
-0
lib/api/repositories.rb
lib/api/repositories.rb
+4
-1
lib/gitlab/backend/shell.rb
lib/gitlab/backend/shell.rb
+7
-2
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+23
-6
No files found.
CHANGELOG
View file @
678f3ddd
...
...
@@ -15,6 +15,7 @@ v 7.3.0
- API: filter issues by labels (Julien Bianchi)
- Add system hook for ssh key changes
- Add blob permalink link (Ciro Santilli)
- Create annotated tags through UI and API (Sean Edge)
v 7.2.0
- Explore page
...
...
app/controllers/projects/tags_controller.rb
View file @
678f3ddd
...
...
@@ -14,7 +14,8 @@ class Projects::TagsController < Projects::ApplicationController
def
create
result
=
CreateTagService
.
new
.
execute
(
@project
,
params
[
:tag_name
],
params
[
:ref
],
current_user
)
params
[
:ref
],
params
[
:message
],
current_user
)
if
result
[
:status
]
==
:success
@tag
=
result
[
:tag
]
redirect_to
project_tags_path
(
@project
)
...
...
app/models/repository.rb
View file @
678f3ddd
...
...
@@ -64,10 +64,10 @@ class Repository
gitlab_shell
.
add_branch
(
path_with_namespace
,
branch_name
,
ref
)
end
def
add_tag
(
tag_name
,
ref
)
def
add_tag
(
tag_name
,
ref
,
message
=
nil
)
Rails
.
cache
.
delete
(
cache_key
(
:tag_names
))
gitlab_shell
.
add_tag
(
path_with_namespace
,
tag_name
,
ref
)
gitlab_shell
.
add_tag
(
path_with_namespace
,
tag_name
,
ref
,
message
)
end
def
rm_branch
(
branch_name
)
...
...
app/services/create_tag_service.rb
View file @
678f3ddd
class
CreateTagService
def
execute
(
project
,
tag_name
,
ref
,
current_user
)
def
execute
(
project
,
tag_name
,
ref
,
message
,
current_user
)
valid_tag
=
Gitlab
::
GitRefValidator
.
validate
(
tag_name
)
if
valid_tag
==
false
return
error
(
'Tag name invalid'
)
...
...
@@ -11,7 +11,11 @@ class CreateTagService
return
error
(
'Tag already exists'
)
end
repository
.
add_tag
(
tag_name
,
ref
)
if
message
message
.
gsub!
(
/^\s+|\s+$/
,
''
)
end
repository
.
add_tag
(
tag_name
,
ref
,
message
)
new_tag
=
repository
.
find_tag
(
tag_name
)
if
new_tag
...
...
app/views/projects/tags/new.html.haml
View file @
678f3ddd
...
...
@@ -15,6 +15,11 @@
.col-sm-10
=
text_field_tag
:ref
,
params
[
:ref
],
placeholder:
'master'
,
required:
true
,
tabindex:
2
,
class:
'form-control'
.light
Branch name or commit SHA
.form-group
=
label_tag
:message
,
'Message'
,
class:
'control-label'
.col-sm-10
=
text_field_tag
:message
,
nil
,
placeholder:
'Enter message.'
,
required:
false
,
tabindex:
3
,
class:
'form-control'
.light
(Optional) Entering a message will create an annotated tag.
.form-actions
=
submit_tag
'Create tag'
,
class:
'btn btn-create'
,
tabindex:
3
=
link_to
'Cancel'
,
project_tags_path
(
@project
),
class:
'btn btn-cancel'
...
...
doc/api/repositories.md
View file @
678f3ddd
...
...
@@ -50,6 +50,7 @@ Parameters:
-
`id`
(required) - The ID of a project
-
`tag_name`
(required) - The name of a tag
-
`ref`
(required) - Create tag using commit SHA, another tag name, or branch name.
-
`message`
(optional) - Creates annotated tag.
```
json
[
...
...
lib/api/repositories.rb
View file @
678f3ddd
...
...
@@ -32,12 +32,15 @@ module API
# id (required) - The ID of a project
# tag_name (required) - The name of the tag
# ref (required) - Create tag from commit sha or branch
# message (optional) - Specifying a message creates an annotated tag.
# Example Request:
# POST /projects/:id/repository/tags
post
':id/repository/tags'
do
authorize_push_project
message
=
params
[
:message
]
||
nil
result
=
CreateTagService
.
new
.
execute
(
user_project
,
params
[
:tag_name
],
params
[
:ref
],
current_user
)
params
[
:ref
],
message
,
current_user
)
if
result
[
:status
]
==
:success
present
result
[
:tag
],
with:
Entities
::
RepoObject
,
...
...
lib/gitlab/backend/shell.rb
View file @
678f3ddd
...
...
@@ -107,12 +107,17 @@ module Gitlab
# path - project path with namespace
# tag_name - new tag name
# ref - HEAD for new tag
# message - optional message for tag (annotated tag)
#
# Ex.
# add_tag("gitlab/gitlab-ci", "v4.0", "master")
# add_tag("gitlab/gitlab-ci", "v4.0", "master", "message")
#
def
add_tag
(
path
,
tag_name
,
ref
)
system
"
#{
gitlab_shell_path
}
/bin/gitlab-projects"
,
"create-tag"
,
"
#{
path
}
.git"
,
tag_name
,
ref
def
add_tag
(
path
,
tag_name
,
ref
,
message
=
nil
)
cmd
=
%W(
#{
gitlab_shell_path
}
/bin/gitlab-projects create-tag
#{
path
}
.git
#{
tag_name
}
#{
ref
}
)
cmd
<<
message
unless
message
.
nil?
||
message
.
empty?
system
*
cmd
end
# Remove repository tag
...
...
spec/requests/api/repositories_spec.rb
View file @
678f3ddd
...
...
@@ -23,12 +23,29 @@ describe API::API, api: true do
end
describe
'POST /projects/:id/repository/tags'
do
it
'should create a new tag'
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
user
),
tag_name:
'v2.0.0'
,
ref:
'master'
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
'v2.0.0'
context
'lightweight tags'
do
it
'should create a new tag'
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
user
),
tag_name:
'v1.0.0'
,
ref:
'master'
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
'v1.0.0'
end
end
context
'annotated tag'
do
it
'should create a new annotated tag'
do
post
api
(
"/projects/
#{
project
.
id
}
/repository/tags"
,
user
),
tag_name:
'v1.0.0'
,
ref:
'master'
,
message:
'tag message'
response
.
status
.
should
==
201
json_response
[
'name'
].
should
==
'v1.0.0'
# The message is not part of the JSON response.
# Additional changes to the gitlab_git gem may be required.
# json_response['message'].should == 'tag message'
end
end
it
'should deny for user without push access'
do
...
...
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