Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to create discussion instead of note #1468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add ability to create discussion instead of note
  • Loading branch information
till0xff committed Nov 20, 2023
commit 62c7d22e12e9ed540dd8c2327643592376b5c9fe
7 changes: 6 additions & 1 deletion lib/danger/request_sources/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 26,7 @@ def initialize(ci_source, environment)
@endpoint = environment["DANGER_GITLAB_API_BASE_URL"] || environment.fetch("CI_API_V4_URL", "https://gitlab.com/api/v4")
@host = environment.fetch("DANGER_GITLAB_HOST", URI.parse(endpoint).host) || "gitlab.com"
@token = environment["DANGER_GITLAB_API_TOKEN"]
@use_threads = environment.fetch("DANGER_GITLAB_USE_THREADS", "").match?(/true|1/i)
end

def client
Expand Down Expand Up @@ -218,7 219,11 @@ def update_pull_request_with_inline_comments!(warnings: [], errors: [], messages

comment_result =
if should_create_new_comment
client.create_merge_request_note(ci_source.repo_slug, ci_source.pull_request_id, body)
if @use_threads
client.create_merge_request_discussion(ci_source.repo_slug, ci_source.pull_request_id, { body: body })
else
client.create_merge_request_note(ci_source.repo_slug, ci_source.pull_request_id, body)
end
else
client.edit_merge_request_note(ci_source.repo_slug, ci_source.pull_request_id, last_comment.id, body)
end
Expand Down