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/rspec/stub.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, Stub
Constant Summary collapse
- VERSION =
'0.7.0'
Instance Method Summary collapse
-
#commit(message) { ... } ⇒ Object
Add and commit local files to this branch.
-
#create!(**options) ⇒ Boolean
Create a pull request.
-
#initialize(base:, branch:, user_name: nil, user_email: nil, verbose: false) ⇒ PrComet
constructor
A new instance of PrComet.
Constructor Details
#initialize(base:, branch:, user_name: nil, user_email: nil, verbose: false) ⇒ PrComet
Note:
You have to set ENV
Returns a new instance of PrComet.
20 21 22 23 24 25 26 27 28 |
# File 'lib/pr_comet.rb', line 20 def initialize(base:, branch:, user_name: nil, user_email: nil, verbose: false) 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, verbose: verbose) @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
37 38 39 40 41 42 43 44 45 |
# File 'lib/pr_comet.rb', line 37 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 rescue PrComet::Errors::ExistUncommittedModify raise `git status` end |
#create!(**options) ⇒ Boolean
Create a pull request. You should call #commit before calling this method. If you want to create a blank PR, you can do it with ‘validate: false` option.
rubocop:disable Metrics/AbcSize
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pr_comet.rb', line 74 def create!(**) [:validate] = true if [:validate].nil? return false if [:validate] && !git_condition_valid? git.push(github_token_url, topic_branch) pr_number = github.create_pull_request(**(**)) github.add_labels(pr_number, *[:labels]) unless [:labels].nil? unless [:project_column_name].nil? github.add_to_project(pr_number, **(**)) end true end |