Commit 13156549 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '345349-catch-danger-insufficient-permission' into 'master'

Warn when Danger cannot apply labels

See merge request gitlab-org/gitlab!74274
parents d6bb2517 bed49308
......@@ -19,10 +19,17 @@ anything_to_post = status_report.values.any? { |data| data.any? }
return unless helper.ci?
if project_helper.labels_to_add.any?
def post_labels
gitlab.api.update_merge_request(gitlab.mr_json['project_id'],
gitlab.mr_json['iid'],
add_labels: project_helper.labels_to_add.join(','))
rescue Gitlab::Error::Forbidden
labels = project_helper.labels_to_add.map { |label| %Q(~"#{label}") }
warn("This Merge Request needs to be labelled with #{labels.join(' ')}. Please request a reviewer or maintainer to add them.")
end
if project_helper.labels_to_add.any?
post_labels
end
if anything_to_post
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment