Class: Rebaser::OpenBranchFetcher
- Inherits:
-
Object
- Object
- Rebaser::OpenBranchFetcher
- Defined in:
- lib/rebaser/open_branch_fetcher.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(username:, password:, token:, remote:, rebase_branch:) ⇒ OpenBranchFetcher
constructor
A new instance of OpenBranchFetcher.
Constructor Details
#initialize(username:, password:, token:, remote:, rebase_branch:) ⇒ OpenBranchFetcher
Returns a new instance of OpenBranchFetcher.
5 6 7 8 9 10 11 |
# File 'lib/rebaser/open_branch_fetcher.rb', line 5 def initialize(username:, password:, token:, remote:, rebase_branch:) @username = username @password = password @token = token @remote = remote @rebase_branch = rebase_branch end |
Instance Method Details
#fetch ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rebaser/open_branch_fetcher.rb', line 13 def fetch github = Github.new do |config| config.basic_auth = "#{username}:#{password}" if token config. = {headers: {'X-GitHub-OTP' => token}} end config.auto_pagination = true end remote_user = remote.split('/').first remote_repo = remote.split('/').last pull_requests = github.pull_requests.list remote_user, remote_repo, state: 'open' branches = pull_requests.map { |pr| pr.head.ref if pr.base.ref === rebase_branch }.compact branches end |