ghreview 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -4
  3. data/bin/ghreview +25 -9
  4. metadata +32 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce2de0113e8615ab9b75756cbcd625d46aba35bca5c45115611169b72164d69d
4
- data.tar.gz: a0db5223db97769709d44e0363d0cbb8d89222d59e3f18b4c6cc3cec438b694e
3
+ metadata.gz: d1337d11f3c8935e886f3970d5b22a95d9098088431e710de5a0ab0a5a51e059
4
+ data.tar.gz: cb4497a211ab18d5b3bfd26ae07460e2b3448d09e585266962cc9bc6d1557068
5
5
  SHA512:
6
- metadata.gz: 29b8d6676cf2f720d7103795535d3897ccf604f5feee5a8b52a62e09e7c12456cd1b3834da10f695167994c7f4f319a5b17bf805bd421110ec92c1a01c1acb78
7
- data.tar.gz: de5dfb542e5fb7ad3ae63cbae85f80ef6984b71eadbe1c308d88d7d89c7ad8dc51af3a852fd1531dede1a65b7cfcfa8a6ee45bca96c9b15ca121a194b9b6f11c
6
+ metadata.gz: f3f0c9e37a817d21a7b22eb46cc38e8fba5c9f6e1a0e3621200dcca3533d2ff17578c24e6dc33b2a889ee8841a895e46cff8afc7d50dba3e925bb7db5bcfe747
7
+ data.tar.gz: 294d7edf99cb7ffa843148b81df46b1322005653ab137caa1631307ae257650b0bbbe5dfae19333c3e68964dd962623b06a8eacd414445ee8027730b9d77b9b4
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # `ghreview` - Mass GitHub Review from Command Line
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/ghreview.svg)](https://badge.fury.io/rb/ghreview)
4
+
5
+
3
6
  Sometimes you need to review a lot of pull requests with the same or very similar
4
7
  small change. Using the GitHub web UI is not convenient for approving many pull
5
- requests, for that purpose we have this `review.rb` helper script which can be
8
+ requests. That's the reason for creating the `ghreview` script which can be
6
9
  used from command line.
7
10
 
8
11
  ## Features
@@ -13,6 +16,7 @@ used from command line.
13
16
  - It can approve each pull request with the default "LGTM" message (Looks Good
14
17
  To Me), but you can use a custom message, see the [options](#options) below
15
18
  - Optionally can merge the pull requests and delete the source branch
19
+ - The pull requests can be passed as arguments or they can be read from a file
16
20
 
17
21
  If a pull request is not approved then it is skipped and not touched at all.
18
22
  You need to comment at the GitHub pull request page manually in that case.
@@ -30,6 +34,8 @@ ghreview --merge https://github.com/yast/yast-users/pull/218 \
30
34
  https://github.com/yast/yast-sound/pull/35
31
35
  ```
32
36
 
37
+ Or use the `--file` option to read them from a file.
38
+
33
39
  ## Installation
34
40
 
35
41
  The script is packaged as a Ruby gem, to install it run:
@@ -66,7 +72,7 @@ Just make sure the `.netrc` file is not readable for the other users
66
72
  Alternatively the access token can be passed via environment variable `GH_TOKEN`:
67
73
 
68
74
  ```shell
69
- ␣GH_TOKEN=... ./review ...
75
+ ␣GH_TOKEN=... ghreview ...
70
76
  ```
71
77
 
72
78
  :warning: *Note the extra space at the beginning of the line, that is
@@ -81,5 +87,7 @@ The script accepts these optional command line options:
81
87
  - `--delete` (or `-d`) - Delete the source branch after merging (the YaST
82
88
  GitHub repositories have now enabled the auto-removal of the merged branches
83
89
  so this option is usually not needed)
84
- - `--message` (or `-m`) - The text used in the, the default is `LGTM`
85
- (Looks Good To Me)
90
+ - `--message <message>` (or `-m <message>`) - The text used in the review
91
+ comment, the default is `LGTM` (Looks Good To Me)
92
+ - `--file <file>` (or `-f <file>`) - Read the list of pull requests from a file
93
+ (one pull request per line)
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # This script is intended for mass review of the same (or very similar)
4
5
  # GitHub pull requests.
@@ -22,11 +23,16 @@ require "rainbow"
22
23
  merge_pr = false
23
24
  delete_branch = false
24
25
  message = "LGTM"
26
+ file = nil
25
27
 
26
28
  # parse the command line options
27
29
  OptionParser.new do |parser|
28
30
  parser.banner = "Usage: #{$PROGRAM_NAME} [options] PR_URL1 PR_URL2 ..."
29
31
 
32
+ parser.on("-f", "--file FILE", "Read the list of pull requests from file") do |f|
33
+ file = f
34
+ end
35
+
30
36
  parser.on("-g", "--merge", "Merge the approved pull requests") do |m|
31
37
  merge_pr = m
32
38
  end
@@ -35,7 +41,7 @@ OptionParser.new do |parser|
35
41
  delete_branch = d
36
42
  end
37
43
 
38
- parser.on("-m", "--message", "Approving message (default: \"#{message}\")") do |m|
44
+ parser.on("-m", "--message MESSAGE", "Approving message (default: \"#{message}\")") do |m|
39
45
  message = m
40
46
  end
41
47
  end.parse!
@@ -99,7 +105,7 @@ def print_pull_status(client, status_url, repo, pr)
99
105
 
100
106
  status = client.status(repo, sha)
101
107
  color = (status[:state] == "success") ? :green : :red
102
- puts "Overall Status: " + Rainbow("#{status[:state]}").color(color)
108
+ puts "Overall Status: " + Rainbow((status[:state]).to_s).color(color)
103
109
 
104
110
  if status[:state] != "success"
105
111
  status[:statuses].each do |st|
@@ -161,18 +167,28 @@ def process_pull(client, pr_url, repo, pr, message, delete_branch, merge_pr)
161
167
 
162
168
  if pull[:merged]
163
169
  puts Rainbow("Already merged").bright.yellow
164
- else
165
- approve_pull(client, pull, message, repo, pr, delete_branch, merge_pr) if ask_for_approval
170
+ elsif ask_for_approval
171
+ approve_pull(client, pull, message, repo, pr, delete_branch, merge_pr)
166
172
  end
167
173
  end
168
174
 
169
- client = create_github_client
170
- ARGV.each do |p|
171
- if p =~ /^https:\/\/github.com\/(\S+)\/pull\/(\d+)/
175
+ def process_url(client, url, message, delete_branch, merge_pr)
176
+ if url =~ /^https:\/\/github.com\/(\S+)\/pull\/(\d+)/
172
177
  repo = Regexp.last_match[1]
173
178
  pr = Regexp.last_match[2]
174
- process_pull(client, p, repo, pr, message, delete_branch, merge_pr)
179
+ process_pull(client, url, repo, pr, message, delete_branch, merge_pr)
175
180
  else
176
- puts "Argument #{p.inspect} is not a GitHub pull request URL, skipping"
181
+ puts "#{url.inspect} is not a GitHub pull request URL, skipping"
177
182
  end
178
183
  end
184
+
185
+ client = create_github_client
186
+ ARGV.each do |url|
187
+ process_url(client, url, message, delete_branch, merge_pr)
188
+ end
189
+
190
+ return unless file
191
+
192
+ File.open(file, "r").each_line do |line|
193
+ process_url(client, line, message, delete_branch, merge_pr)
194
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghreview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ladislav Slezák
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-30 00:00:00.000000000 Z
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: netrc
@@ -90,9 +90,37 @@ dependencies:
90
90
  - - "<"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '3.0'
93
+ - !ruby/object:Gem::Dependency
94
+ name: rake
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '13'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '13'
107
+ - !ruby/object:Gem::Dependency
108
+ name: rubocop
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '='
112
+ - !ruby/object:Gem::Version
113
+ version: 0.71.0
114
+ type: :development
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '='
119
+ - !ruby/object:Gem::Version
120
+ version: 0.71.0
93
121
  description: |2
94
- The 'ghreview' tools allows doing mass GitHub pull request reviews from
95
- command line. It is indented for approving simple changes is several
122
+ The 'ghreview' tool allows doing mass GitHub pull request reviews from
123
+ command line. It is intended for approving simple changes is several
96
124
  pull requests even across several repositories.
97
125
  email:
98
126
  executables: