Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Add delete label parameter #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ Set the status message for `concourse-ci` context on specified pull request.

* `label`: *Optional.* A label to add to the pull request.

* `delete_label`: *Optional.* A label to remove from the pull request.

## Example pipeline

Please see this repo's [pipeline](https://github.com/jtarchie/pullrequest-resource/blob/master/.concourse.yml) for a perfect example.
Expand Down
11 changes: 11 additions & 0 deletions assets/lib/commands/out.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ def output
metadata << { 'name' => 'label', 'value' => params.label }
end

if params.delete_label
label_exists = Octokit.labels_for_issue(input.source.repo, id).select do |hash|
hash.to_hash[:name] == params.delete_label
end

if label_exists.any?
Octokit.remove_label(input.source.repo, id, params.delete_label)
end
metadata << { 'name' => 'delete_label', 'value' => params.delete_label }
end

if params.merge.method
commit_msg = if params.merge.commit_msg
commit_path = File.join(destination, params.merge.commit_msg)
Expand Down