Class: PrComet
- Inherits:
-
Object
- Object
- PrComet
- Defined in:
- lib/pr_comet.rb,
lib/pr_comet/errors.rb,
lib/pr_comet/version.rb,
lib/pr_comet/git/command.rb,
lib/pr_comet/command_line.rb,
lib/pr_comet/github/client.rb
Overview
Helps to create a pull request
Defined Under Namespace
Modules: CommandLine, Errors, Git, Github
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Method Summary collapse
-
#commit(message) { ... } ⇒ Object
Add and commit local files to this branch.
-
#create!(title:, body:, labels: nil) ⇒ Boolean
Create a pull request You should call #commit before calling this method.
-
#initialize(base:, branch:, user_name: nil, user_email: nil) ⇒ PrComet
constructor
A new instance of PrComet.
Constructor Details
#initialize(base:, branch:, user_name: nil, user_email: nil) ⇒ PrComet
Note:
You have to set ENV
Returns a new instance of PrComet.
19 20 21 22 23 24 25 26 27 |
# File 'lib/pr_comet.rb', line 19 def initialize(base:, branch:, user_name: nil, user_email: nil) raise "You have to set ENV['GITHUB_ACCESS_TOKEN']" if access_token.nil? @base_branch = base @topic_branch = branch @git = Git::Command.new(user_name: user_name, user_email: user_email) @github = Github::Client.new(access_token, git.remote_url('origin')) @initial_sha1 = git.current_sha1 end |
Instance Method Details
#commit(message) { ... } ⇒ Object
Add and commit local files to this branch
36 37 38 39 40 41 42 |
# File 'lib/pr_comet.rb', line 36 def commit(, &block) git.checkout_with(topic_branch) unless git.current_branch?(topic_branch) result = modify_files(&block) if block_given? git.add('.') git.commit() result end |
#create!(title:, body:, labels: nil) ⇒ Boolean
Create a pull request You should call #commit before calling this method
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pr_comet.rb', line 51 def create!(title:, body:, labels: nil) return false unless git_condition_valid? git.push(github_token_url, topic_branch) pr_number = github.create_pull_request( base: base_branch, head: topic_branch, title: title, body: body ) github.add_labels(pr_number, *labels) unless labels.nil? true end |