Class: Octopolo::GitHub::PullRequest
- Extended by:
- CLIWrapper, ConfigWrapper, UserConfigWrapper
- Defined in:
- lib/octopolo/github/pull_request.rb
Constant Summary
Constants inherited from Issue
Issue::CommentFailed, Issue::MissingParameter, Issue::NotFound
Instance Attribute Summary
Attributes included from CLIWrapper
Attributes included from ConfigWrapper
Attributes included from UserConfigWrapper
Attributes inherited from Issue
Class Method Summary collapse
-
.closed(repo_name) ⇒ Object
Public: All closed pull requests for a given repo.
-
.create(repo_name, options) ⇒ Object
Public: Create a pull request for the given repo.
- .current ⇒ Object
Instance Method Summary collapse
- #author_names ⇒ Object
- #branch ⇒ Object
- #commenter_names ⇒ Object
- #commits ⇒ Object
- #data ⇒ Object
- #mergeable? ⇒ Boolean
- #status ⇒ Object
- #status_checks_passed? ⇒ Boolean
- #week ⇒ Object
Methods inherited from Issue
#add_labels, #body, #comments, #exclude_octopolo_user, #external_urls, #human_app_name, #initialize, #remove_labels, #title, #url, #write_comment
Constructor Details
This class inherits a constructor from Octopolo::GitHub::Issue
Class Method Details
.closed(repo_name) ⇒ Object
Public: All closed pull requests for a given repo
repo_name - Full name (“account/repo”) of the repo in question
Returns an Array of PullRequest objects
18 19 20 21 22 |
# File 'lib/octopolo/github/pull_request.rb', line 18 def self.closed repo_name GitHub.pull_requests(repo_name, "closed").map do |data| new repo_name, data.number, data end end |
.create(repo_name, options) ⇒ Object
Public: Create a pull request for the given repo
repo_name - Full name (“account/repo”) of the repo in question options - Hash of pull request information
title: Title of the pull request
description: Brief description of the pull request
release: Boolean indicating if the pull request is for Release
destination_branch: Which branch to merge into
source_branch: Which branch to be merged
Returns a PullRequest instance
35 36 37 38 39 40 |
# File 'lib/octopolo/github/pull_request.rb', line 35 def self.create repo_name, # create via the API creator = PullRequestCreator.perform(repo_name, ) # wrap in our class new repo_name, creator.number, creator.data end |
.current ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/octopolo/github/pull_request.rb', line 80 def self.current current_branch = Git.current_branch query = "repo:#{config.github_repo} type:pr is:open head:#{current_branch}" pulls = GitHub.search_issues(query) if pulls.total_count!= 1 cli.say "Multiple pull requests found for branch #{current_branch}" if pulls.total_count > 1 cli.say "No pull request found for branch #{current_branch}" if pulls.total_count < 1 return nil else cli.say "Pull request for current branch is number #{pulls.items.first.number}" pulls.items.first end rescue => e cli.say "An error occurred while getting the current branch: #{e.}" return nil end |
Instance Method Details
#author_names ⇒ Object
64 65 66 |
# File 'lib/octopolo/github/pull_request.rb', line 64 def exclude_octopolo_user commits.map(&:author_name).uniq end |
#branch ⇒ Object
48 49 50 |
# File 'lib/octopolo/github/pull_request.rb', line 48 def branch data.head.ref end |
#commenter_names ⇒ Object
60 61 62 |
# File 'lib/octopolo/github/pull_request.rb', line 60 def commenter_names exclude_octopolo_user (comments.map{ |comment| GitHub::User.new(comment.user.login). }.uniq - ) end |
#commits ⇒ Object
68 69 70 |
# File 'lib/octopolo/github/pull_request.rb', line 68 def commits @commits ||= Commit.for_pull_request self end |
#data ⇒ Object
42 43 44 45 46 |
# File 'lib/octopolo/github/pull_request.rb', line 42 def data @data ||= GitHub.pull_request(repo_name, number) rescue Octokit::NotFound raise NotFound end |
#mergeable? ⇒ Boolean
52 53 54 |
# File 'lib/octopolo/github/pull_request.rb', line 52 def mergeable? data.mergeable end |
#status ⇒ Object
76 77 78 |
# File 'lib/octopolo/github/pull_request.rb', line 76 def status GitHub.status(repo_name, data.head.sha)[:state] end |
#status_checks_passed? ⇒ Boolean
72 73 74 |
# File 'lib/octopolo/github/pull_request.rb', line 72 def status_checks_passed? status == 'success' end |