export-pull-requests 0.3.0 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Changes +27 -0
  3. data/README.md +9 -5
  4. data/bin/epr +48 -19
  5. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 016a62a2e3de917954ac3d80513c491938d48b50
4
- data.tar.gz: 9ae66c248e9221b8cc00abdcdf34caf66ba72e0c
3
+ metadata.gz: 9aa3a32a54b67ebcc317255f9575cd1cb92eabef
4
+ data.tar.gz: e614ed2ff03d1d3571513fe0923bf0162bc45c38
5
5
  SHA512:
6
- metadata.gz: 0fff380fb343736b01c1af4ff0e77fb788d6eaa76f3f59ddc9be2da0074ebfe66d296aca68d8c178f0e24bcf2143c04d3cb99e97d7cd68c0517fe49b498bd050
7
- data.tar.gz: fcdb405a3e51b4210019c9a9c343d173f5d72823968ecdc9a860ff6e32b882f868300e9aaef8a677592904c0ecbd7ff2da5b05a136ab6079d54f7e0c766af950
6
+ metadata.gz: d584c1f5406cba8733a910513a8079f37d2544cc07656f0484a856d4d38b0121892e9ef49cd809bca61a614ec75f27d2491f1af4a02dad7ac65685224013061a
7
+ data.tar.gz: 53b26f30445b60c26955e2212396cd069ab262374a50876938f40b7c131d91472bd3aebf43093738428d8181e298a3020b167aac23df7b5018e8dc1768507ce1
data/Changes CHANGED
@@ -1,3 +1,30 @@
1
+ v0.3.5 2021-03-16
2
+ --------------------
3
+ Enhancements:
4
+ * Add Merged column containing PR merge time
5
+ * Exit with failure if attempting to export GitHub milestones for PRs
6
+
7
+ v0.3.4 2021-02-12
8
+ --------------------
9
+ Bug Fixes:
10
+ * Bitbucket username not exported for PRs under 2.0 API (#20)
11
+
12
+ v0.3.3 2019-05-01
13
+ --------------------
14
+ Bug Fixes:
15
+ * GitHub PR only exports were output as an "issue" instead of "PR"
16
+
17
+ v0.3.2 2019-02-09
18
+ --------------------
19
+ Bug Fixes:
20
+ * Don't supply assignee or milestone for GitHub if nil
21
+
22
+ --------------------
23
+ v0.3.1 2019-01-28
24
+ --------------------
25
+ Enhancements:
26
+ * Add support for filtering on milestones and labels to GitLab
27
+
1
28
  --------------------
2
29
  v0.3.0 2019-01-10
3
30
  --------------------
data/README.md CHANGED
@@ -20,9 +20,9 @@ This installs the `epr` executable.
20
20
  -b, --body Include the issue/pr body description in the output (GitHub only)
21
21
  -c, --creator=USER1,USER2,... Export PRs created by given username(s); prepend `!' to exclude user
22
22
  -e, --endpoint=URL Endpoint URL for 'enterprise', etc... repositories
23
- -m, --milestone=WHAT Export items assigned to the given milestone (GitHub only)
24
- -a, --assignee=USER Export items assigned to the given user (GitHub only)
25
- -l, --labels=LABEL(S) Export items with the given label(s) (GitHub only)
23
+ -m, --milestone=WHAT Export items assigned to the given milestone (GitHub/GitLab only)
24
+ -a, --assignee=USER Export items assigned to the given user (GitHub/GitLab only)
25
+ -l, --labels=LABEL(S) Export items with the given label(s) (GitHub/GitLab only)
26
26
  -h, --help Show this message
27
27
  -p, --provider=NAME Service provider: bitbucket, github, or gitlab; defaults to github
28
28
  -s, --state=STATE Export items in the given state, defaults to open
@@ -66,12 +66,16 @@ Export all issues from a GitLab project:
66
66
 
67
67
  ## Service Notes
68
68
 
69
- To connect to a custom/"Enterprise" installation of any of the supported services use the endpoint option (`-e`)
69
+ To connect to a custom/"Enterprise" installation of any of the supported services use the endpoint option (`-e`).
70
+
71
+ The provided URL must point the API endpoint, not the user-facing site. For GitHub this is `http(s)://YOUR-SITE/api/v3`.
70
72
 
71
73
  ### Bitbucket
72
74
 
73
75
  You can use [app passwords](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html) for the API token.
74
- Just provide your token HTTP Auth style using: `username:app_password`.
76
+ Just provide your token info in `bitbucket_username:app_password` format:
77
+
78
+ epr -p bitbucket -t bitbucket_username:app_password user/repo1
75
79
 
76
80
  ### GitLab
77
81
 
data/bin/epr CHANGED
@@ -9,7 +9,7 @@ require "github_api"
9
9
  require "gitlab"
10
10
  require "bitbucket_rest_api"
11
11
 
12
- VERSION = "0.3.0"
12
+ VERSION = "0.3.5"
13
13
  SERVICES = %w[github gitlab bitbucket]
14
14
  GIT_CONFIGS = %w[epr.token github.oauth-token]
15
15
 
@@ -70,13 +70,14 @@ def bitbucket(user, repo)
70
70
 
71
71
  prs = $bitbucket.repos.pull_request.all(user, repo, :page => page, :state => $filter.upcase)
72
72
  prs["values"].each do |pr|
73
- next if pr.author && skip_user?(pr.author.username)
73
+ next if pr.author && (skip_user?(pr.author.display_name) || skip_user?(pr.author.nickname))
74
74
 
75
75
  rows << [
76
76
  repo_name,
77
77
  TYPE_PR,
78
78
  pr.id,
79
- pr.author ? pr.author.username : no_user,
79
+ # With the 2.0 API is this check necessary?
80
+ pr.author ? pr.author.display_name : no_user,
80
81
  pr.title,
81
82
  pr.state,
82
83
  localtime(pr.created_on),
@@ -138,12 +139,12 @@ def github(user, repo)
138
139
  options[:endpoint] = $endpoint if $endpoint
139
140
 
140
141
  $gh ||= Github.new(options)
141
- $gh.public_send(method).list(:user => user,
142
- :repo => repo,
143
- :state => $filter,
144
- :milestone => $milestone,
145
- :assignee => $assignee,
146
- :labels => $labels).each_page do |page|
142
+
143
+ options = { :user => user, :repo => repo, :state => $filter, :labels => $labels }
144
+ options[:milestone] = $milestone if $milestone
145
+ options[:assignee] = $assignee if $assignee
146
+
147
+ $gh.public_send(method).list(options).each_page do |page|
147
148
 
148
149
  next if page.size.zero? # Needed for auto_pagination
149
150
 
@@ -154,16 +155,28 @@ def github(user, repo)
154
155
 
155
156
  rows << [
156
157
  "#{user}/#{repo}",
157
- item.pull_request ? TYPE_PR : TYPE_ISSUE,
158
+ # If we're only retrieving PRs then item.pull_request will be nil
159
+ # It's only populated when retrieving both (issues method).
160
+ item.pull_request || method == :pull_requests ? TYPE_PR : TYPE_ISSUE,
158
161
  item.number,
159
162
  item.user.login,
160
163
  item.title,
161
164
  item.state,
162
165
  localtime(item.created_at),
163
- localtime(item.updated_at),
164
- item.html_url,
166
+ localtime(item.updated_at)
165
167
  ]
166
168
 
169
+ # GitHub issues API returns PRs but not their merged_at time. To get that we need to specifically export PRs
170
+ if item.pull_request && $export != EXPORT_ISSUES
171
+ rows[-1] << "(use `-x pr` option)"
172
+ elsif $export != EXPORT_PRS
173
+ rows[-1] << "N/A"
174
+ else
175
+ rows[-1] << (item.merged_at ? localtime(item.merged_at) : nil)
176
+ end
177
+
178
+ rows[-1] << item.html_url
179
+
167
180
  if $body
168
181
  body = item.body
169
182
  # -3 for "..."
@@ -190,10 +203,18 @@ def gitlab(user, repo)
190
203
 
191
204
  # Do we care about this differing in output?
192
205
  state = $filter == "open" ? "opened" : $filter
206
+ options = {
207
+ :milestone => $milestone,
208
+ :labels => $labels,
209
+ :state => state
210
+ }
211
+
212
+ # If assignee_id is nil an error is raised
213
+ options[:assignee_id] = $assignee if $assignee
193
214
 
194
215
  $gitlab ||= Gitlab.client(:auth_token => $token, :endpoint => $endpoint || "https://gitlab.com/api/v4")
195
216
  methods.each do |method|
196
- $gitlab.public_send(method, "#{user}/#{repo}", :state => state).auto_paginate do |item|
217
+ $gitlab.public_send(method, "#{user}/#{repo}", options).auto_paginate do |item|
197
218
  next if skip_user?(item.author.username)
198
219
 
199
220
  rows << [
@@ -205,9 +226,16 @@ def gitlab(user, repo)
205
226
  item.title,
206
227
  item.state,
207
228
  localtime(item.created_at),
208
- localtime(item.updated_at),
209
- item.web_url
229
+ localtime(item.updated_at)
210
230
  ]
231
+
232
+ if method == :issues
233
+ rows[-1] << "N/A"
234
+ else
235
+ rows[-1] << (item.merged_at ? localtime(item.merged_at) : nil)
236
+ end
237
+
238
+ rows[-1] << item.web_url
211
239
  end
212
240
  end
213
241
 
@@ -216,13 +244,14 @@ end
216
244
 
217
245
  def export_repos(argv)
218
246
  rows = []
219
- rows << %w[Repository Type # User Title State Created Updated URL]
247
+ rows << %w[Repository Type # User Title State Created Updated Merged URL]
220
248
  rows[-1].insert(4, "Body") if $body
221
249
 
222
250
  repos = parse_repos(argv)
223
251
  repos.each do |user, repo|
224
252
  case $provider
225
253
  when "github"
254
+ abort "milestone filtering can only be used with issues" if $milestone && $export == EXPORT_PRS
226
255
  rows.concat(github(user, repo))
227
256
  when "gitlab"
228
257
  rows.concat(gitlab(user, repo))
@@ -267,15 +296,15 @@ parser = OptionParser.new do |opts|
267
296
  $endpoint = url
268
297
  end
269
298
 
270
- opts.on "-m", "--milestone=WHAT", "Export items assigned to the given milestone (GitHub only)" do |m|
299
+ opts.on "-m", "--milestone=WHAT", "Export items assigned to the given milestone (GitHub/GitLab only)" do |m|
271
300
  $milestone = m
272
301
  end
273
302
 
274
- opts.on "-a", "--assignee=USER", "Export items assigned to the given user (GitHub only)" do |a|
303
+ opts.on "-a", "--assignee=USER", "Export items assigned to the given user (GitHub/GitLab only)" do |a|
275
304
  $assignee = a
276
305
  end
277
306
 
278
- opts.on "-l", "--labels=LABEL(S)", "Export items with the given label(s) (GitHub only)" do |l|
307
+ opts.on "-l", "--labels=LABEL(S)", "Export items with the given label(s) (GitHub/GitLab only)" do |l|
279
308
  $labels = l
280
309
  end
281
310
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: export-pull-requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-10 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github_api
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.9'
61
+ version: 12.3.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0.9'
68
+ version: 12.3.3
69
69
  description: Program to export GitHub, GitLab, or Bitbucket pull requests/merge requests
70
70
  and issues to CSV a file.
71
71
  email: skye.shaw@gmail.com