lib/github_ext/plugin.rb in danger-github_ext-0.0.2 vs lib/github_ext/plugin.rb in danger-github_ext-0.0.3

- old
+ new

@@ -20,10 +20,26 @@ # # @example List current statuses for the head commit # # github.statuses # + # @example Update the title of the pull request + # + # github.update_pr_tile 'Updated title' + # + # @example Update the body of the pull request + # + # github.update_pr_body 'Updated body' + # + # @example Close the pull request + # + # github.close + # + # @example Open the pull request + # + # github.open + # # @see duck8823/danger-github_ext # @tags github # class DangerGithubExt < DangerfileGitHubPlugin @@ -89,8 +105,44 @@ }) end statuses.map {|_, val| val.sort{|a, b| b[:date] <=> a[:date] }[0] } + end + + # Update the title of the pull request + # @return [Sawyer::Resource] + # + def update_pr_title(title) + @repo ||= self.pr_json.base.repo.full_name + @number ||= self.pr_json.number + self.api.update_pull_request(@repo, @number, {:title => title}) + end + + # Update the body of pull request + # @return [Sawyer::Resource] + # + def update_pr_body(body) + @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 + # @return [Sawyer::Resource] + # + def close + @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'}) end end end