Skip to content

Commit

Permalink
[GitLab] Create a new comment
Browse files Browse the repository at this point in the history
Current implementation of GitLab request source does not create a new comment
when requested via the `--new-comment` CLI option, but rather updates the old
one.

This patch fixes the issue by checking whether new comment is requested
before updating Pull Request.

Preliminary discussion of this issue is here:
danger#1084
  • Loading branch information
AlexDenisov committed Feb 22, 2019
1 parent 6b14d4b commit cccfd84
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/danger/request_sources/gitlab.rb
Expand Up @@ -133,7 +133,7 @@ def update_pull_request!(warnings: [], errors: [], messages: [], markdowns: [],
danger_id: danger_id,
template: "gitlab")

if editable_comments.empty?
if editable_comments.empty? or should_create_new_comment
client.create_merge_request_comment(
ci_source.repo_slug, ci_source.pull_request_id, body
)
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/danger/request_sources/gitlab_spec.rb
Expand Up @@ -231,7 +231,7 @@
messages: violations_factory(["Test message"]),
template: "gitlab"
)
stub_request(:put, "https://gitlab.com/api/v4/projects/k0nserv%2Fdanger-test/merge_requests/1/notes/13471894").with(
stub_request(:post, "https://gitlab.com/api/v4/projects/k0nserv%2Fdanger-test/merge_requests/1/notes").with(
body: {
body: body
},
Expand Down

0 comments on commit cccfd84

Please sign in to comment.