Class: HubMerge::Prompts
- Inherits:
-
Object
- Object
- HubMerge::Prompts
- Defined in:
- lib/hubmerge/prompts.rb
Class Method Summary collapse
- .github_token ⇒ Object
- .pull_requests_to_merge(pull_requests) ⇒ Object
- .query ⇒ Object
- .repo(github_client) ⇒ Object
- .repo_from_pr(pr) ⇒ Object
- .say(text) ⇒ Object
Class Method Details
.github_token ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/hubmerge/prompts.rb', line 16 def self.github_token github_token = TTY::Prompt.new.mask( "Enter a github access token: (create one at https://github.com/settings/tokens)" ) puts <<~EOF To make this easier next time, you can set the `GITHUB_TOKEN` environment variable EOF github_token end |
.pull_requests_to_merge(pull_requests) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hubmerge/prompts.rb', line 26 def self.pull_requests_to_merge(pull_requests) choices = pull_requests.map { |pr| { name: "#{self.repo_from_pr(pr)}##{pr.number} - #{pr.title}", value: pr, } } TTY::Prompt.new.multi_select( "Which of these pull requests do you want to merge? (SPACE to select, ENTER to finalize)", choices, echo: false, per_page: 20, filter: true ) end |
.query ⇒ Object
9 10 11 12 13 14 |
# File 'lib/hubmerge/prompts.rb', line 9 def self.query TTY::Prompt.new.ask( "Enter a GitHub search query to find PRs (example: 'in:title automerge')", default: "author:app/dependabot" ) end |
.repo(github_client) ⇒ Object
3 4 5 6 7 |
# File 'lib/hubmerge/prompts.rb', line 3 def self.repo(github_client) TTY::Prompt.new.ask( "Enter a GitHub repository to look for PRs in: (example: 'rails/rails')" ) end |
.repo_from_pr(pr) ⇒ Object
43 44 45 46 47 |
# File 'lib/hubmerge/prompts.rb', line 43 def self.repo_from_pr(pr) # GitHub doesn't return a full repository name in the response, only way # to avoid an extra API call is to parse the `repository_url` string pr.repository_url.sub("https://api.github.com/repos/", "") end |
.say(text) ⇒ Object
49 50 51 |
# File 'lib/hubmerge/prompts.rb', line 49 def self.say(text) puts text end |