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
b45ee2c3
Commit
b45ee2c3
authored
Dec 16, 2015
by
Mike Wyatt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better support for referencing and closing issues in asana_service.rb
parent
28a8d0b5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
8 deletions
+41
-8
app/models/project_services/asana_service.rb
app/models/project_services/asana_service.rb
+20
-8
spec/models/project_services/asana_service_spec.rb
spec/models/project_services/asana_service_spec.rb
+21
-0
No files found.
app/models/project_services/asana_service.rb
View file @
b45ee2c3
...
...
@@ -98,17 +98,29 @@ automatically inspected. Leave blank to include all branches.'
task_list
=
[]
close_list
=
[]
message
.
split
(
"
\n
"
).
each
do
|
line
|
# look for a task ID or a full Asana url
task_list
.
concat
(
line
.
scan
(
/#(\d+)/
))
task_list
.
concat
(
line
.
scan
(
/https:\/\/app\.asana\.com\/\d+\/\d+\/(\d+)/
))
# look for a word starting with 'fix' followed by a task ID
close_list
.
concat
(
line
.
scan
(
/(fix\w*)\W*#(\d+)/i
))
# matches either:
# - #1234
# - https://app.asana.com/0/0/1234
# optionally preceded with:
# - fix/ed/es/ing
# - close/s/d
# - closing
issue_finder
=
/(fix\w*|clos[ei]\w*+)?\W*(?:https:\/\/app\.asana\.com\/\d+\/\d+\/(\d+)|#(\d+))/i
message
.
scan
(
issue_finder
).
each
do
|
tuple
|
# tuple will be
# [ 'fix', 'id_from_url', 'id_from_pound' ]
taskid
=
tuple
[
2
]
||
tuple
[
1
]
task_list
.
push
(
taskid
)
if
tuple
[
0
]
close_list
.
push
(
taskid
)
end
end
# post commit to every taskid found
task_list
.
each
do
|
taskid
|
task
=
Asana
::
Task
.
find
(
taskid
[
0
]
)
task
=
Asana
::
Task
.
find
(
taskid
)
if
task
task
.
create_story
(
text:
push_msg
+
' '
+
message
)
...
...
@@ -117,7 +129,7 @@ automatically inspected. Leave blank to include all branches.'
# close all tasks that had 'fix(ed/es/ing) #:id' in them
close_list
.
each
do
|
taskid
|
task
=
Asana
::
Task
.
find
(
taskid
.
last
)
task
=
Asana
::
Task
.
find
(
taskid
)
if
task
task
.
modify
(
completed:
true
)
...
...
spec/models/project_services/asana_service_spec.rb
View file @
b45ee2c3
...
...
@@ -62,5 +62,26 @@ describe AsanaService, models: true do
@asana
.
check_commit
(
'fix #456789'
,
'pushed'
)
end
it
'should be able to close via url'
do
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'42'
).
twice
@asana
.
check_commit
(
'closes https://app.asana.com/19292/956299/42'
,
'pushed'
)
end
it
'should allow multiple matches per line'
do
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'123'
).
twice
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'456'
).
twice
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'789'
).
once
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'42'
).
once
expect
(
Asana
::
Task
).
to
receive
(
:find
).
with
(
'12'
).
twice
message
=
<<-
EOF
minor bigfix, refactoring, fixed #123 and Closes #456 work on #789
ref https://app.asana.com/19292/956299/42 and closing https://app.asana.com/19292/956299/12
EOF
@asana
.
check_commit
(
message
,
'pushed'
)
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