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
cc1aecdb
Commit
cc1aecdb
authored
Jul 21, 2018
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement the `tag` commands
parent
2022243a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+17
-0
spec/services/quick_actions/interpret_service_spec.rb
spec/services/quick_actions/interpret_service_spec.rb
+45
-0
No files found.
app/services/quick_actions/interpret_service.rb
View file @
cc1aecdb
...
@@ -582,6 +582,23 @@ module QuickActions
...
@@ -582,6 +582,23 @@ module QuickActions
@updates
[
:confidential
]
=
true
@updates
[
:confidential
]
=
true
end
end
desc
'Tag this commit.'
explanation
do
|
(
tag_name
),
_
|
"Tags this commit to
#{
tag_name
}
."
end
params
'v1.2.3 <message>'
parse_params
do
|
tag_name_and_message
|
tag_name_and_message
.
split
(
' '
,
2
)
end
condition
do
issuable
.
is_a?
(
Commit
)
# TODO authorize
end
command
:tag
do
|
(
tag_name
,
message
)
|
@updates
[
:tag_name
]
=
tag_name
@updates
[
:tag_message
]
=
message
end
def
extract_users
(
params
)
def
extract_users
(
params
)
return
[]
if
params
.
nil?
return
[]
if
params
.
nil?
...
...
spec/services/quick_actions/interpret_service_spec.rb
View file @
cc1aecdb
...
@@ -6,6 +6,7 @@ describe QuickActions::InterpretService do
...
@@ -6,6 +6,7 @@ describe QuickActions::InterpretService do
let
(
:developer2
)
{
create
(
:user
)
}
let
(
:developer2
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
,
title:
'9.10'
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
,
title:
'9.10'
)
}
let
(
:commit
)
{
create
(
:commit
,
project:
project
)
}
let
(
:inprogress
)
{
create
(
:label
,
project:
project
,
title:
'In Progress'
)
}
let
(
:inprogress
)
{
create
(
:label
,
project:
project
,
title:
'In Progress'
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'Bug'
)
}
let
(
:bug
)
{
create
(
:label
,
project:
project
,
title:
'Bug'
)
}
let
(
:note
)
{
build
(
:note
,
commit_id:
merge_request
.
diff_head_sha
)
}
let
(
:note
)
{
build
(
:note
,
commit_id:
merge_request
.
diff_head_sha
)
}
...
@@ -347,6 +348,14 @@ describe QuickActions::InterpretService do
...
@@ -347,6 +348,14 @@ describe QuickActions::InterpretService do
end
end
end
end
shared_examples
'tag command'
do
it
'tags a commit'
do
_
,
updates
=
service
.
execute
(
content
,
issuable
)
expect
(
updates
).
to
eq
(
tag_name:
tag_name
,
tag_message:
tag_message
)
end
end
it_behaves_like
'reopen command'
do
it_behaves_like
'reopen command'
do
let
(
:content
)
{
'/reopen'
}
let
(
:content
)
{
'/reopen'
}
let
(
:issuable
)
{
issue
}
let
(
:issuable
)
{
issue
}
...
@@ -1102,6 +1111,32 @@ describe QuickActions::InterpretService do
...
@@ -1102,6 +1111,32 @@ describe QuickActions::InterpretService do
it_behaves_like
'empty command'
it_behaves_like
'empty command'
end
end
end
end
context
'/tag command'
do
let
(
:issuable
)
{
commit
}
context
'ignores command with no argument'
do
it_behaves_like
'empty command'
do
let
(
:content
)
{
'/tag'
}
end
end
context
'tags a commit with a tag name'
do
it_behaves_like
'tag command'
do
let
(
:tag_name
)
{
'v1.2.3'
}
let
(
:tag_message
)
{
nil
}
let
(
:content
)
{
"/tag
#{
tag_name
}
"
}
end
end
context
'tags a commit with a tag name and message'
do
it_behaves_like
'tag command'
do
let
(
:tag_name
)
{
'v1.2.3'
}
let
(
:tag_message
)
{
'Stable release'
}
let
(
:content
)
{
"/tag
#{
tag_name
}
#{
tag_message
}
"
}
end
end
end
end
end
describe
'#explain'
do
describe
'#explain'
do
...
@@ -1319,5 +1354,15 @@ describe QuickActions::InterpretService do
...
@@ -1319,5 +1354,15 @@ describe QuickActions::InterpretService do
expect
(
explanations
).
to
eq
([
"Moves this issue to test/project."
])
expect
(
explanations
).
to
eq
([
"Moves this issue to test/project."
])
end
end
end
end
describe
'tag a commit'
do
let
(
:content
)
{
'/tag 1.2.3 some message'
}
it
'includes the tag name'
do
_
,
explanations
=
service
.
explain
(
content
,
commit
)
expect
(
explanations
).
to
eq
([
"Tags this commit to 1.2.3."
])
end
end
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