octo_merge 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/octo-merge +14 -4
- data/lib/octo_merge/interactive_pull_requests.rb +46 -0
- data/lib/octo_merge/list_pull_requests.rb +20 -0
- data/lib/octo_merge/pull_request.rb +1 -8
- data/lib/octo_merge/version.rb +1 -1
- data/lib/octo_merge.rb +10 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc888e5760a08871d2d68cd5e43044e4cc03eb92
|
4
|
+
data.tar.gz: e715350366209678d5c31d315ac5d905ef9e1904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 777dc01da1a20b0c2df6711089a0fce0a065a76e789c7c1aae5a9948c96ad0ee14954929ce222c77cf47839873da37584efd432c4b74ed9f9663741af05a6748
|
7
|
+
data.tar.gz: 53660d4e55248fff632d5cee36c71cc32c3024047769b3a6aaf12bbad188a740764425224e538538cd4f7d0a5ee0dc2eccf0bc7df743d706add9379713a917f3
|
data/exe/octo-merge
CHANGED
@@ -41,6 +41,14 @@ OptionParser.new do |opts|
|
|
41
41
|
options[:strategy] = strategy
|
42
42
|
end
|
43
43
|
|
44
|
+
opts.on("--query=QUERY", "Query to use in interactive mode (e.g.: 'label:ready-to-merge')") do |query|
|
45
|
+
options[:query] = query
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on('--interactive', 'Select PullRequests within an interactive session') do |interactive|
|
49
|
+
options[:interactive] = interactive
|
50
|
+
end
|
51
|
+
|
44
52
|
opts.on('-h', '--help', 'Display this screen') do
|
45
53
|
puts opts
|
46
54
|
exit
|
@@ -52,15 +60,17 @@ OptionParser.new do |opts|
|
|
52
60
|
end
|
53
61
|
end.parse!
|
54
62
|
|
55
|
-
options[:dir] = File.expand_path(options[:dir])
|
56
|
-
options[:pull_requests] = options[:pull_requests].split(",")
|
57
|
-
options[:strategy] = Object.const_get("OctoMerge::#{options[:strategy]}")
|
58
|
-
|
59
63
|
OctoMerge.configure do |config|
|
60
64
|
config.login = options[:login]
|
61
65
|
config.password = options[:password]
|
62
66
|
end
|
63
67
|
|
68
|
+
options[:dir] = File.expand_path(options[:dir])
|
69
|
+
options[:strategy] = Object.const_get("OctoMerge::#{options[:strategy]}")
|
70
|
+
|
71
|
+
options[:pull_requests] = OctoMerge::InteractivePullRequests.get(options) if options[:interactive]
|
72
|
+
options[:pull_requests] = options[:pull_requests].to_s.split(",")
|
73
|
+
|
64
74
|
OctoMerge.run(
|
65
75
|
repo: options[:repo],
|
66
76
|
pull_request_numbers: options[:pull_requests],
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module OctoMerge
|
2
|
+
# TODO: Write specs
|
3
|
+
class InteractivePullRequests
|
4
|
+
def initialize(repo:, query:)
|
5
|
+
@repo = repo
|
6
|
+
@query = query
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.get(options = {})
|
10
|
+
new(repo: options[:repo], query: options[:query]).pull_requests
|
11
|
+
end
|
12
|
+
|
13
|
+
def pull_requests
|
14
|
+
display_pull_requests
|
15
|
+
display_input_message
|
16
|
+
|
17
|
+
gets.strip
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :repo, :query
|
23
|
+
|
24
|
+
def display_pull_requests
|
25
|
+
puts "[INFO] Fetching PullRequests. Please wait ...\n\n"
|
26
|
+
|
27
|
+
list.all.each do |pull_request|
|
28
|
+
puts format_pull_request(pull_request)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def display_input_message
|
33
|
+
puts "\n\nPlease enter the pull requests you want to merge: (e.g.: '23,42,66'):\n\n"
|
34
|
+
print "$: "
|
35
|
+
end
|
36
|
+
|
37
|
+
def format_pull_request(pull_request)
|
38
|
+
"* #{pull_request.number}:\t\"#{pull_request.title}\" by @#{pull_request.user.login}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def list
|
42
|
+
@list = OctoMerge::ListPullRequests.new(repo: repo, query: query)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module OctoMerge
|
2
|
+
class ListPullRequests
|
3
|
+
attr_reader :repo, :query
|
4
|
+
|
5
|
+
def initialize(repo:, query:)
|
6
|
+
@repo = repo
|
7
|
+
@query = query
|
8
|
+
end
|
9
|
+
|
10
|
+
def all
|
11
|
+
@all ||= github_client.search_issues("is:open is:pr repo:#{repo} #{query}")[:items]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def github_client
|
17
|
+
OctoMerge.github_client
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -32,14 +32,7 @@ module OctoMerge
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def github_client
|
35
|
-
|
36
|
-
login: config.login,
|
37
|
-
password: config.password
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def config
|
42
|
-
OctoMerge.configuration
|
35
|
+
OctoMerge.github_client
|
43
36
|
end
|
44
37
|
end
|
45
38
|
end
|
data/lib/octo_merge/version.rb
CHANGED
data/lib/octo_merge.rb
CHANGED
@@ -4,6 +4,8 @@ require "octo_merge/configuration"
|
|
4
4
|
require "octo_merge/context"
|
5
5
|
require "octo_merge/execute"
|
6
6
|
require "octo_merge/git"
|
7
|
+
require "octo_merge/interactive_pull_requests"
|
8
|
+
require "octo_merge/list_pull_requests"
|
7
9
|
require "octo_merge/pull_request"
|
8
10
|
|
9
11
|
require "octo_merge/abstract_merge"
|
@@ -23,11 +25,19 @@ module OctoMerge
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def configure
|
28
|
+
@github_client = nil
|
26
29
|
yield(configuration)
|
27
30
|
end
|
28
31
|
|
29
32
|
def configuration
|
30
33
|
@configuration ||= Configuration.new
|
31
34
|
end
|
35
|
+
|
36
|
+
def github_client
|
37
|
+
@github_client ||= Octokit::Client.new(
|
38
|
+
login: configuration.login,
|
39
|
+
password: configuration.password
|
40
|
+
)
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octo_merge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Helm
|
@@ -134,6 +134,8 @@ files:
|
|
134
134
|
- lib/octo_merge/context.rb
|
135
135
|
- lib/octo_merge/execute.rb
|
136
136
|
- lib/octo_merge/git.rb
|
137
|
+
- lib/octo_merge/interactive_pull_requests.rb
|
138
|
+
- lib/octo_merge/list_pull_requests.rb
|
137
139
|
- lib/octo_merge/merge_with_rebase.rb
|
138
140
|
- lib/octo_merge/merge_without_rebase.rb
|
139
141
|
- lib/octo_merge/pull_request.rb
|