lib/github_ext/plugin.rb in danger-github_ext-0.0.3 vs lib/github_ext/plugin.rb in danger-github_ext-0.0.4
- old
+ new
@@ -47,39 +47,53 @@
super(dangerfile)
self.api.auto_paginate = true
end
- # Whether mergeable and mergeable status is clean
+ # Determine if pull request is mergeable and mergeable status is clean
# @return [boolean]
#
def mergeable?
self.pr_json.attrs[:mergeable_state] == 'clean' && github.pr_json.attrs[:mergeable]
end
- # Get labels
+ # List labels for the pull request
# @return [[String]]
+ # @deprecated Please use {#pr_labels} instead
#
def labels
@repo ||= self.pr_json.base.repo.full_name
@number ||= self.pr_json.number
self.api.labels_for_issue(@repo, @number).map { |issue|
issue.name
}
end
- # add labels to pull request
+ # Add labels to the pull request
# @param [[String]] labels
# @return [void]
#
def add_labels(labels)
@repo ||= self.pr_json.base.repo.full_name
@number ||= self.pr_json.number
self.api.add_labels_to_an_issue(@repo, @number, Array(labels))
end
- # remove labels from pull request
+ # Add label with color to the pull request
+ # @param [String] label
+ # @param [String] color
+ # @return [void]
+ #
+ def add_label(label, color = 'ffffff')
+ @repo ||= self.pr_json.base.repo.full_name
+ @number ||= self.pr_json.number
+ self.api.update_label(@repo, label, {:color => color})
+ self.api.add_labels_to_an_issue(@repo, @number, Array(label))
+
+ end
+
+ # Remove labels from the pull request
# @param [[String]] labels
# @return [void]
#
def remove_labels(labels)
@repo ||= self.pr_json.base.repo.full_name
@@ -87,11 +101,11 @@
Array(labels).each do |label|
self.api.remove_label(@repo, @number, label)
end
end
- # get current commit statuses
+ # List current statuses for the head commit
# @return [[Hash]]
#
def statuses
@repo ||= self.pr_json.base.repo.full_name
@sha ||= self.head_commit
@@ -125,24 +139,15 @@
@repo ||= self.pr_json.base.repo.full_name
@number ||= self.pr_json.number
self.api.update_pull_request(@repo, @number, {:body => body})
end
- # Close the pull request
+ # Update the pull request state
# @return [Sawyer::Resource]
#
- def close
+ def update_pr_state(state)
@repo ||= self.pr_json.base.repo.full_name
@number ||= self.pr_json.number
- self.api.update_pull_request(@repo, @number, {:state => 'closed'})
- end
-
- # Open the pull request
- # @return [Sawyer::Resource]
- #
- def open
- @repo ||= self.pr_json.base.repo.full_name
- @number ||= self.pr_json.number
- self.api.update_pull_request(@repo, @number, {:state => 'open'})
+ self.api.update_pull_request(@repo, @number, {:state => state})
end
end
end