summaryrefslogtreecommitdiff
path: root/app/services/todo_service.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-03-08 18:22:50 +0000
committerSean McGivern <sean@gitlab.com>2016-05-17 10:17:45 +0100
commit6b834f2cbcfc26fe3123b6682ed7e20618e31d1b (patch)
tree0b812d498079fdcaaf0d004a5bce716560b99be0 /app/services/todo_service.rb
parent78a67fc48dab434b43a080e5b15491963656661a (diff)
downloadgitlab-ce-6b834f2cbcfc26fe3123b6682ed7e20618e31d1b.tar.gz
Create a todo on failing MR build
When a build fails for a commit, create a todo for the author of the merge request that commit is the HEAD of. If the commit isn't the HEAD commit of any MR, don't do anything. If there already is a todo for that user and MR, don't do anything. Current limitations: - This isn't configurable by project. - The author of a merge request might not be the person who pushed the breaking commit.
Diffstat (limited to 'app/services/todo_service.rb')
-rw-r--r--app/services/todo_service.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb
index 42c5bca90fd..4bf4e144727 100644
--- a/app/services/todo_service.rb
+++ b/app/services/todo_service.rb
@@ -80,6 +80,30 @@ class TodoService
mark_pending_todos_as_done(merge_request, current_user)
end
+ # When a build fails on the HEAD of a merge request we should:
+ #
+ # * create a todo for that user to fix it
+ #
+ def merge_request_build_failed(merge_request)
+ create_build_failed_todo(merge_request)
+ end
+
+ # When a new commit is pushed to a merge request we should:
+ #
+ # * mark all pending todos related to the merge request for that user as done
+ #
+ def merge_request_push(merge_request, current_user)
+ mark_pending_todos_as_done(merge_request, current_user)
+ end
+
+ # When a build is retried to a merge request we should:
+ #
+ # * mark all pending todos related to the merge request for the author as done
+ #
+ def merge_request_build_retried(merge_request)
+ mark_pending_todos_as_done(merge_request, merge_request.author)
+ end
+
# When create a note we should:
#
# * mark all pending todos related to the noteable for the note author as done
@@ -145,6 +169,12 @@ class TodoService
create_todos(mentioned_users, attributes)
end
+ def create_build_failed_todo(merge_request)
+ author = merge_request.author
+ attributes = attributes_for_todo(merge_request.project, merge_request, author, Todo::BUILD_FAILED)
+ create_todos(author, attributes)
+ end
+
def attributes_for_target(target)
attributes = {
project_id: target.project.id,