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

Commit

Permalink
Add delete label parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
YonatanKiron committed Jun 10, 2018
1 parent 348d93d commit 7e72f82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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' => '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

0 comments on commit 7e72f82

Please sign in to comment.