Class: BuPr::Handlers::Github
- Inherits:
-
Object
- Object
- BuPr::Handlers::Github
- Defined in:
- lib/bu_pr/handlers/github.rb
Instance Attribute Summary collapse
-
#base ⇒ String
readonly
Base branch name.
-
#current ⇒ String
readonly
Current branch.
- #linker ⇒ CompareLinker readonly
- #repo ⇒ String readonly
- #title ⇒ String readonly
- #token ⇒ String readonly
Class Method Summary collapse
-
.call(config:, current_branch:) ⇒ Object
Entry point.
Instance Method Summary collapse
- #call ⇒ Object
-
#create_pull_request ⇒ Integer
Pull-request ID.
- #diff_comment(pr_number) ⇒ Object
-
#initialize(config:, current_branch:) ⇒ Github
constructor
A new instance of Github.
Constructor Details
#initialize(config:, current_branch:) ⇒ Github
Returns a new instance of Github.
29 30 31 32 33 34 35 |
# File 'lib/bu_pr/handlers/github.rb', line 29 def initialize config:, current_branch: @current = current_branch @base = config.branch @repo = config.repo @title = config.title @token = config.token end |
Instance Attribute Details
#base ⇒ String (readonly)
Returns base branch name.
9 10 11 |
# File 'lib/bu_pr/handlers/github.rb', line 9 def base @base end |
#current ⇒ String (readonly)
Returns current branch.
10 11 12 |
# File 'lib/bu_pr/handlers/github.rb', line 10 def current @current end |
#linker ⇒ CompareLinker (readonly)
14 15 16 |
# File 'lib/bu_pr/handlers/github.rb', line 14 def linker @linker end |
#repo ⇒ String (readonly)
11 12 13 |
# File 'lib/bu_pr/handlers/github.rb', line 11 def repo @repo end |
#title ⇒ String (readonly)
12 13 14 |
# File 'lib/bu_pr/handlers/github.rb', line 12 def title @title end |
#token ⇒ String (readonly)
13 14 15 |
# File 'lib/bu_pr/handlers/github.rb', line 13 def token @token end |
Class Method Details
.call(config:, current_branch:) ⇒ Object
Entry point
20 21 22 23 24 25 |
# File 'lib/bu_pr/handlers/github.rb', line 20 def self.call config:, current_branch: new( config: config, current_branch: current_branch ).call end |
Instance Method Details
#call ⇒ Object
37 38 39 |
# File 'lib/bu_pr/handlers/github.rb', line 37 def call diff_comment create_pull_request end |
#create_pull_request ⇒ Integer
Returns pull-request ID.
42 43 44 45 46 47 48 49 50 |
# File 'lib/bu_pr/handlers/github.rb', line 42 def create_pull_request res = client.create_pull_request \ repo, base, current, title res[:number] end |
#diff_comment(pr_number) ⇒ Object
53 54 55 56 |
# File 'lib/bu_pr/handlers/github.rb', line 53 def diff_comment pr_number load_linker pr_number linker.add_comment repo, pr_number, comment_content end |