Class: Octopolo::GitHub::PullRequestCreator
- Inherits:
-
IssueCreator
- Object
- IssueCreator
- Octopolo::GitHub::PullRequestCreator
- Defined in:
- lib/octopolo/github/pull_request_creator.rb
Constant Summary
Constants inherited from IssueCreator
IssueCreator::CannotCreate, IssueCreator::MissingAttribute, IssueCreator::NotYetCreated
Instance Attribute Summary
Attributes inherited from IssueCreator
#data, #number, #options, #repo_name
Attributes included from ConfigWrapper
Instance Method Summary collapse
-
#body_edit_temp_name ⇒ Object
Public: Temporary file for body editing.
-
#destination_branch ⇒ Object
Public: Branch to merge the pull request into.
-
#draft ⇒ Object
Public: Draft Pull request.
-
#initialize(repo_name, options) ⇒ PullRequestCreator
constructor
Public: Create a pull request for the given repo with the given options.
-
#perform ⇒ Object
Public: Create the pull request.
-
#renderer_template ⇒ Object
Public: Rendering template for body property.
-
#source_branch ⇒ Object
Public: Branch to merge into the destination branch.
Methods inherited from IssueCreator
#body, #body_locals, #edit_body, #jira_ids, #jira_url, perform, #pivotal_ids, #title
Constructor Details
#initialize(repo_name, options) ⇒ PullRequestCreator
Public: Create a pull request for the given repo with the given options
repo_name - Full name (“account/repo”) of the repo in question options - Hash of pull request information
title: Title of the pull request
destination_branch: Which branch to merge into
source_branch: Which branch to be merged
16 17 18 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 16 def initialize repo_name, super(repo_name, ) end |
Instance Method Details
#body_edit_temp_name ⇒ Object
Public: Temporary file for body editing
Returns Name of temporary file
71 72 73 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 71 def body_edit_temp_name 'octopolo_pull_request' end |
#destination_branch ⇒ Object
Public: Branch to merge the pull request into
Returns a String with the branch name
50 51 52 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 50 def destination_branch [:destination_branch] || raise(MissingAttribute) end |
#draft ⇒ Object
Public: Draft Pull request
Returns a boolean that marks the PR a draft PR
43 44 45 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 43 def draft ![:skip_draft] end |
#perform ⇒ Object
Public: Create the pull request
Returns an array with the first element being the pull request’s number, the second being a Mash of the response from GitHub’s API
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 24 def perform result = GitHub.create_pull_request( repo_name, destination_branch, source_branch, title, body, {draft: draft} ) # capture the information self.number = result.number self.data = result rescue => e raise CannotCreate, e. end |
#renderer_template ⇒ Object
Public: Rendering template for body property
Returns Name of template file
64 65 66 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 64 def renderer_template Renderer::PULL_REQUEST_BODY end |
#source_branch ⇒ Object
Public: Branch to merge into the destination branch
Returns a String with the branch name
57 58 59 |
# File 'lib/octopolo/github/pull_request_creator.rb', line 57 def source_branch [:source_branch] || raise(MissingAttribute) end |