hubmerge 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/hubmerge +3 -0
- data/hubmerge.gemspec +32 -0
- data/lib/hubmerge/merger.rb +60 -0
- data/lib/hubmerge/options.rb +55 -0
- data/lib/hubmerge/prompts.rb +47 -0
- data/lib/hubmerge/spinner.rb +43 -0
- data/lib/hubmerge/version.rb +3 -0
- data/lib/hubmerge.rb +108 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 39534401c1ee1e7c7251b9fa4d1a539d76e7bd5bb32da1c7177789b13f5ce119
|
4
|
+
data.tar.gz: efa9b1237baeeec7cd9b8458d142b8d7a3c14797b82b9d6dac7d3bc2f414df06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16e70d1e9830a7337554bbc7d6a03945056cf88f1710cb333f7e124866414ab3cccf2ae017998a20983154a9ccd688240edafe1e5a9f581fec1bb2dd1910f497
|
7
|
+
data.tar.gz: 55c8416a9ffce1d278635656b31abb94ebfc1d56534922ec5f08463ec7a7440100e74d5d1ca35a34b3da6711dad67d1fc1faab1453cbe360bf701f1d81d0a83a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hubmerge (0.0.1)
|
5
|
+
octokit (~> 4.0)
|
6
|
+
tty-prompt (~> 0.18)
|
7
|
+
tty-spinner (~> 0.9)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
|
+
equatable (0.5.0)
|
15
|
+
faraday (0.15.4)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
minitest (5.11.3)
|
18
|
+
multipart-post (2.0.0)
|
19
|
+
necromancer (0.4.0)
|
20
|
+
octokit (4.13.0)
|
21
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
22
|
+
pastel (0.7.2)
|
23
|
+
equatable (~> 0.5.0)
|
24
|
+
tty-color (~> 0.4.0)
|
25
|
+
public_suffix (3.0.3)
|
26
|
+
rake (10.5.0)
|
27
|
+
sawyer (0.8.1)
|
28
|
+
addressable (>= 2.3.5, < 2.6)
|
29
|
+
faraday (~> 0.8, < 1.0)
|
30
|
+
timers (4.3.0)
|
31
|
+
tty-color (0.4.3)
|
32
|
+
tty-cursor (0.6.1)
|
33
|
+
tty-prompt (0.18.1)
|
34
|
+
necromancer (~> 0.4.0)
|
35
|
+
pastel (~> 0.7.0)
|
36
|
+
timers (~> 4.0)
|
37
|
+
tty-cursor (~> 0.6.0)
|
38
|
+
tty-reader (~> 0.5.0)
|
39
|
+
tty-reader (0.5.0)
|
40
|
+
tty-cursor (~> 0.6.0)
|
41
|
+
tty-screen (~> 0.6.4)
|
42
|
+
wisper (~> 2.0.0)
|
43
|
+
tty-screen (0.6.5)
|
44
|
+
tty-spinner (0.9.0)
|
45
|
+
tty-cursor (~> 0.6.0)
|
46
|
+
wisper (2.0.0)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
bundler (~> 1.16)
|
53
|
+
hubmerge!
|
54
|
+
minitest (~> 5.0)
|
55
|
+
rake (~> 10.0)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Paul Kuruvilla
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# HubMerge
|
2
|
+
|
3
|
+
HubMerge helps you merge multiple GitHub Pull Requests with a friendly
|
4
|
+
[TUI](https://en.wikipedia.org/wiki/Text-based_user_interface).
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem install hubmerge
|
10
|
+
```
|
11
|
+
|
12
|
+
To authenticate with GitHub, HubMerge expects a `GITHUB_TOKEN` environment
|
13
|
+
variable to be set. Visit [Github > Settings > Personal Access
|
14
|
+
Tokens](https://github.com/settings/tokens) to create one. If this is not set,
|
15
|
+
HubMerge will prompt for the value.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
HubMerge accepts parameters interactively. Just run `hubmerge` to get started.
|
20
|
+
|
21
|
+
$ hubmerge
|
22
|
+
|
23
|
+
You can provide parameters via the CLI too (good to store in your shell history if you do this often!)
|
24
|
+
|
25
|
+
$ hubmerge --repo "rails/rails" --query "author:app/dependabot"
|
26
|
+
|
27
|
+
By default, `hubmerge` will always ask for confirmation before merging PRs. If you want to avoid this, use the `--yes` flag. This is useful if you're running `hubmerge` as part of a script.
|
28
|
+
|
29
|
+
## Advanced Usage
|
30
|
+
|
31
|
+
HubMerge's primary use case is to merge PRs in a single repository. To support
|
32
|
+
advanced use cases, HubMerge allows using any arbitrary Github [search
|
33
|
+
filter](https://help.github.com/en/articles/searching-issues-and-pull-requests).
|
34
|
+
|
35
|
+
When the `--repo` flag is omitted, the query is directly passed in as a search filter (prefixed with `is:pr is:open`). One can now embed repo/org/user filters into the search query itself.
|
36
|
+
|
37
|
+
_Note_: This isn't supported in interactive mode, only via the CLI.
|
38
|
+
|
39
|
+
**Multiple repositories**
|
40
|
+
|
41
|
+
To merge PRs across multiple repositories:
|
42
|
+
|
43
|
+
$ hubmerge --query "repo:rails/rails repo:sinatra/sinatra author:app/dependabot"
|
44
|
+
|
45
|
+
**Organization wide merges**
|
46
|
+
|
47
|
+
To merge PRs across an entire org:
|
48
|
+
|
49
|
+
$ hubmerge --query "org:rails author:app/dependabot"
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rohitpaulk/hubmerge.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hubmerge"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/hubmerge
ADDED
data/hubmerge.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "hubmerge/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "hubmerge"
|
7
|
+
spec.version = HubMerge::VERSION
|
8
|
+
spec.authors = ["Paul Kuruvilla"]
|
9
|
+
spec.email = ["rohitpaulk@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Merge GitHub PRs in bulk!"
|
12
|
+
spec.description = "A gem to merge multiple GitHub PRs that match a search query"
|
13
|
+
spec.homepage = "https://github.com/rohitpaulk/hubmerge"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
|
29
|
+
spec.add_dependency "octokit", "~> 4.0"
|
30
|
+
spec.add_dependency "tty-prompt", "~> 0.18"
|
31
|
+
spec.add_dependency "tty-spinner", "~> 0.9"
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module HubMerge
|
2
|
+
class RetryError < RuntimeError
|
3
|
+
end
|
4
|
+
|
5
|
+
class UnmergeableError < RuntimeError
|
6
|
+
end
|
7
|
+
|
8
|
+
class Merger
|
9
|
+
MERGEABILITY_RETRY_COUNT = 5
|
10
|
+
MERGEABILITY_RETRY_DELAY = 5
|
11
|
+
|
12
|
+
def self.approve_if_not_approved(gh_client, pr)
|
13
|
+
repo = repo_from_pr(pr)
|
14
|
+
reviews = gh_client.pull_request_reviews(repo, pr.number)
|
15
|
+
unless reviews.find { |review| review.state == "APPROVED" }
|
16
|
+
gh_client.create_pull_request_review(repo, pr.number, event: "APPROVE")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Throws UnmergeableError if not mergeable.
|
21
|
+
# Returns true if mergeable.
|
22
|
+
#
|
23
|
+
# Yes, this interface is weird. Makes it easier to deal with
|
24
|
+
# spinners.
|
25
|
+
def self.check_mergeability(gh_client, pr)
|
26
|
+
repo = repo_from_pr(pr)
|
27
|
+
|
28
|
+
with_retries(MERGEABILITY_RETRY_COUNT, MERGEABILITY_RETRY_DELAY) do
|
29
|
+
pr = gh_client.pull_request(repo, pr.number)
|
30
|
+
if pr.mergeable
|
31
|
+
return true
|
32
|
+
elsif pr.mergeable_state == "unknown"
|
33
|
+
raise RetryError
|
34
|
+
else
|
35
|
+
raise UnmergeableError.new(pr.mergeable_state)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.merge(gh_client, pr)
|
41
|
+
repo = repo_from_pr(pr)
|
42
|
+
gh_client.merge_pull_request(repo, pr.number)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.repo_from_pr(pr)
|
46
|
+
# GitHub doesn't return a full repository name in the response, only way
|
47
|
+
# to avoid an extra API call is to parse the `repository_url` string
|
48
|
+
pr.repository_url.sub("https://api.github.com/repos/", "")
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.with_retries(n_tries, delay)
|
52
|
+
n_tries.times do
|
53
|
+
return yield
|
54
|
+
rescue RetryError
|
55
|
+
sleep delay
|
56
|
+
next
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
module HubMerge
|
4
|
+
class Options
|
5
|
+
def self.all
|
6
|
+
{
|
7
|
+
repo: {
|
8
|
+
short_switch: "-r",
|
9
|
+
long_switch: "--repo ORG/REPONAME",
|
10
|
+
type: String,
|
11
|
+
description: "Github repository to search for PRs in (example: rails/rails)",
|
12
|
+
},
|
13
|
+
|
14
|
+
query: {
|
15
|
+
short_switch: "-q",
|
16
|
+
long_switch: "--query ORG/REPONAME",
|
17
|
+
type: String,
|
18
|
+
description: "GitHub search query to run to find PRs (example: 'author:app/dependabot')",
|
19
|
+
},
|
20
|
+
|
21
|
+
merge_without_confirmation: {
|
22
|
+
short_switch: "-y",
|
23
|
+
long_switch: "--yes",
|
24
|
+
type: :flag,
|
25
|
+
description: "Merge without confirmation from user (default: false)",
|
26
|
+
},
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.parse(argv)
|
31
|
+
parsed = {}
|
32
|
+
opt_parser = OptionParser.new
|
33
|
+
|
34
|
+
all.each do |key, params|
|
35
|
+
if params[:type] == :flag
|
36
|
+
opt_parser.on(
|
37
|
+
params[:short_switch],
|
38
|
+
params[:long_switch],
|
39
|
+
params[:description]
|
40
|
+
) { |v| parsed[key] = v }
|
41
|
+
else
|
42
|
+
opt_parser.on(
|
43
|
+
params[:short_switch],
|
44
|
+
params[:long_switch],
|
45
|
+
params[:type],
|
46
|
+
params[:description]
|
47
|
+
) { |v| parsed[key] = v }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
opt_parser.parse(argv)
|
52
|
+
parsed
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module HubMerge
|
2
|
+
class Prompts
|
3
|
+
def self.repo(github_client)
|
4
|
+
TTY::Prompt.new.ask(
|
5
|
+
"Enter a GitHub repository to look for PRs in: (example: 'rails/rails')"
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.query
|
10
|
+
TTY::Prompt.new.ask(
|
11
|
+
"Enter a GitHub search query to find PRs (example: 'in:title automerge')",
|
12
|
+
default: "author: app/dependabot"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.github_token
|
17
|
+
github_token = TTY::Prompt.new.mask(
|
18
|
+
"Enter a github access token: (create one at https://github.com/settings/tokens)"
|
19
|
+
)
|
20
|
+
puts <<~EOF
|
21
|
+
To make this easier next time, you can set the `GITHUB_TOKEN` environment variable
|
22
|
+
EOF
|
23
|
+
github_token
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.pull_requests_to_merge(pull_requests)
|
27
|
+
choices = pull_requests.map { |pr|
|
28
|
+
{
|
29
|
+
name: "##{pr.number} - #{pr.title}",
|
30
|
+
value: pr,
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
TTY::Prompt.new.multi_select(
|
35
|
+
"Which of these pull requests do you want to merge? (SPACE to select, ENTER to finalize)",
|
36
|
+
choices,
|
37
|
+
echo: false,
|
38
|
+
per_page: 20,
|
39
|
+
filter: true
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.say(text)
|
44
|
+
puts text
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module HubMerge
|
2
|
+
class SpinnerError < RuntimeError
|
3
|
+
end
|
4
|
+
|
5
|
+
class Spinner
|
6
|
+
def initialize
|
7
|
+
@active_parent_spinner = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_spinner(text)
|
11
|
+
spinner = TTY::Spinner.new(text)
|
12
|
+
spinner.auto_spin
|
13
|
+
yield
|
14
|
+
ensure
|
15
|
+
spinner.stop
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_parent(text)
|
19
|
+
@active_parent_spinner = TTY::Spinner::Multi.new(text)
|
20
|
+
yield
|
21
|
+
ensure
|
22
|
+
@active_parent_spinner = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def with_child(text)
|
26
|
+
ensure_active_parent!
|
27
|
+
|
28
|
+
spinner = @active_parent_spinner.register(text)
|
29
|
+
spinner.auto_spin
|
30
|
+
result = yield
|
31
|
+
spinner.success
|
32
|
+
result
|
33
|
+
rescue SpinnerError => e
|
34
|
+
spinner.error(e.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def ensure_active_parent!
|
38
|
+
unless !!@active_parent_spinner
|
39
|
+
raise "#with_parent not called!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/hubmerge.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require "octokit"
|
2
|
+
require "tty-prompt"
|
3
|
+
require "tty-spinner"
|
4
|
+
|
5
|
+
require "hubmerge/version"
|
6
|
+
|
7
|
+
require "hubmerge/options"
|
8
|
+
require "hubmerge/prompts"
|
9
|
+
require "hubmerge/merger"
|
10
|
+
require "hubmerge/spinner"
|
11
|
+
|
12
|
+
module HubMerge
|
13
|
+
class Executable
|
14
|
+
def initialize(opts = {})
|
15
|
+
# Overrides only used in tests
|
16
|
+
@spinner = opts[:spinner] || Spinner.new
|
17
|
+
@prompts = opts[:prompts] || Prompts
|
18
|
+
@github_client = opts[:github_client]
|
19
|
+
@merger = opts[:merger] || Merger
|
20
|
+
end
|
21
|
+
|
22
|
+
def run(env, argv)
|
23
|
+
check_or_prompt_github_token(env)
|
24
|
+
opts = Options.parse(argv)
|
25
|
+
|
26
|
+
query = check_or_prompt_search_query(opts)
|
27
|
+
prs = search_pull_requests(query)
|
28
|
+
if prs.empty?
|
29
|
+
@prompts.say("No pull requests found. Maybe try refining your search query?")
|
30
|
+
return 1
|
31
|
+
end
|
32
|
+
|
33
|
+
prs_to_merge = if opts[:merge_without_confirmation]
|
34
|
+
prs
|
35
|
+
else
|
36
|
+
@prompts.pull_requests_to_merge(prs)
|
37
|
+
end
|
38
|
+
|
39
|
+
if prs_to_merge.empty?
|
40
|
+
@prompts.say("No pull requests selected, aborting")
|
41
|
+
return 1
|
42
|
+
else
|
43
|
+
merge_pull_requests(prs_to_merge)
|
44
|
+
return 0
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def merge_pull_requests(prs_to_merge)
|
51
|
+
total = prs_to_merge.count
|
52
|
+
prs_to_merge.each_with_index do |pr, index|
|
53
|
+
mergeable = false
|
54
|
+
@spinner.with_parent("[:spinner] PR ##{pr.number} (#{index + 1}/#{total})") do
|
55
|
+
mergeable = @spinner.with_child("[:spinner] Checking mergeability") {
|
56
|
+
begin
|
57
|
+
@merger.check_mergeability(github_client, pr)
|
58
|
+
rescue UnmergeableError => e
|
59
|
+
raise SpinnerError("(Mergability: #{e})")
|
60
|
+
end
|
61
|
+
|
62
|
+
true
|
63
|
+
}
|
64
|
+
|
65
|
+
next unless mergeable
|
66
|
+
|
67
|
+
@spinner.with_child("[:spinner] Approving") do
|
68
|
+
@merger.approve_if_not_approved(github_client, pr)
|
69
|
+
end
|
70
|
+
|
71
|
+
@spinner.with_child("[:spinner] Merging") do
|
72
|
+
@merger.merge(github_client, pr)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def search_pull_requests(query)
|
79
|
+
@spinner.with_spinner("[:spinner] Searching for PRs...") do
|
80
|
+
github_client.search_issues(query).items
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def check_or_prompt_search_query(opts)
|
85
|
+
if opts.key?(:query) && opts.key?(:repo)
|
86
|
+
"is:pr is:open repo:#{opts[:repo]} #{opts[:query]}"
|
87
|
+
elsif opts.key?(:query)
|
88
|
+
"is:pr is:open #{opts[:query]}"
|
89
|
+
else
|
90
|
+
repo = opts[:repo] || @prompts.repo(github_client)
|
91
|
+
query = @prompts.query
|
92
|
+
"is:pr is:open repo:#{repo} #{query}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def check_or_prompt_github_token(env)
|
97
|
+
@github_token = if env.key?("GITHUB_TOKEN")
|
98
|
+
env.fetch("GITHUB_TOKEN")
|
99
|
+
else
|
100
|
+
@prompts.github_token
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def github_client
|
105
|
+
@github_client ||= Octokit::Client.new(access_token: @github_token)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hubmerge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Kuruvilla
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-prompt
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.18'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.18'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tty-spinner
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
97
|
+
description: A gem to merge multiple GitHub PRs that match a search query
|
98
|
+
email:
|
99
|
+
- rohitpaulk@gmail.com
|
100
|
+
executables:
|
101
|
+
- hubmerge
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- exe/hubmerge
|
115
|
+
- hubmerge.gemspec
|
116
|
+
- lib/hubmerge.rb
|
117
|
+
- lib/hubmerge/merger.rb
|
118
|
+
- lib/hubmerge/options.rb
|
119
|
+
- lib/hubmerge/prompts.rb
|
120
|
+
- lib/hubmerge/spinner.rb
|
121
|
+
- lib/hubmerge/version.rb
|
122
|
+
homepage: https://github.com/rohitpaulk/hubmerge
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.7.8
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Merge GitHub PRs in bulk!
|
146
|
+
test_files: []
|