summaryrefslogtreecommitdiff
path: root/app/models/project_services
diff options
context:
space:
mode:
authorMike Wyatt <wyatt.mike@gmail.com>2015-12-16 10:08:05 -0400
committerMike Wyatt <wyatt.mike@gmail.com>2015-12-16 10:08:05 -0400
commitb45ee2c314e2c26f4574f2e973dfa40204860c66 (patch)
treed632ddcb66bba3ab581b389d592690029789d014 /app/models/project_services
parent28a8d0b5db104be6d01ad647aefcd92ec9ec113e (diff)
downloadgitlab-ce-b45ee2c314e2c26f4574f2e973dfa40204860c66.tar.gz
better support for referencing and closing issues in asana_service.rb
Diffstat (limited to 'app/models/project_services')
-rw-r--r--app/models/project_services/asana_service.rb28
1 files changed, 20 insertions, 8 deletions
diff --git a/app/models/project_services/asana_service.rb b/app/models/project_services/asana_service.rb
index e6e16058d41..bbc508e8f8e 100644
--- a/app/models/project_services/asana_service.rb
+++ b/app/models/project_services/asana_service.rb
@@ -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)