export-pull-requests 0.3.1 → 0.3.6

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 +26 -0
  3. data/README.md +8 -3
  4. data/bin/epr +36 -15
  5. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa3cfb134a324a1a09daa690b431a5092b2265c757fadaecd0f87bc0275fcddb
4
- data.tar.gz: 3e85340c807d3a9f8a9a07a11d707f171d19d0322e67f741badc84cdca3806ee
3
+ metadata.gz: 0eeb60967960338e5c26e80b8fc8284b5e94a2c310ff4aa438d902e3a29a8882
4
+ data.tar.gz: ff4a1a83d12a48de37e192238316e796b00dd71ac5710f749863d4ffdc410324
5
5
  SHA512:
6
- metadata.gz: f92e17537078e7f6d7a160c44ad1144538fb999c0eb2689d15801f81f498eeeb8305031d378ffce99821aa48dafdae5e4a74fa7c03efc060ad19ec2d38d1aa33
7
- data.tar.gz: cbe3d1a3ef7a14fd40192ce1574fba71ad2d3f7076d67a652c4b6c9ab0dd0c2321abae4ef20b9ff79460ca40922fce540e48363c08b5728c75fc8e4a597948df
6
+ metadata.gz: 63992bbdfc22722a37a57993ab0420cff9e82884215aae4b2e192c2377d9cf55952654b76a74c1dc554880cfa9938a56fa5c1f429b5f0b2e2771501f001fd99f
7
+ data.tar.gz: bf4f67c8958fb7c9e9f9d7759b2494d48ca35c5d0e004430fb0cc986a7797f10534bddd6bc3a4d91f2d890dd4364e5c5f83f39cadc5e017f36a434f597e7050c
data/Changes CHANGED
@@ -1,3 +1,29 @@
1
+ v0.3.6 2021-04-28
2
+ --------------------
3
+ Bug fixes:
4
+ * Require Ruby < 3 (#25)
5
+
6
+ v0.3.5 2021-03-16
7
+ --------------------
8
+ Enhancements:
9
+ * Add Merged column containing PR merge time
10
+ * Exit with failure if attempting to export GitHub milestones for PRs
11
+
12
+ v0.3.4 2021-02-12
13
+ --------------------
14
+ Bug Fixes:
15
+ * Bitbucket username not exported for PRs under 2.0 API (#20)
16
+
17
+ v0.3.3 2019-05-01
18
+ --------------------
19
+ Bug Fixes:
20
+ * GitHub PR only exports were output as an "issue" instead of "PR"
21
+
22
+ v0.3.2 2019-02-09
23
+ --------------------
24
+ Bug Fixes:
25
+ * Don't supply assignee or milestone for GitHub if nil
26
+
1
27
  --------------------
2
28
  v0.3.1 2019-01-28
3
29
  --------------------
data/README.md CHANGED
@@ -6,7 +6,8 @@ Supports GitHub, GitLab, and Bitbucket.
6
6
 
7
7
  ## Installation
8
8
 
9
- [Ruby](https://www.ruby-lang.org/en/documentation/installation/) is required.
9
+ [Ruby](https://www.ruby-lang.org/en/documentation/installation/) version < 3 is required
10
+ ([why?](https://github.com/sshaw/export-pull-requests/issues/26)).
10
11
 
11
12
  With Ruby installed run:
12
13
 
@@ -66,12 +67,16 @@ Export all issues from a GitLab project:
66
67
 
67
68
  ## Service Notes
68
69
 
69
- To connect to a custom/"Enterprise" installation of any of the supported services use the endpoint option (`-e`)
70
+ To connect to a custom/"Enterprise" installation of any of the supported services use the endpoint option (`-e`).
71
+
72
+ The provided URL must point the API endpoint, not the user-facing site. For GitHub this is `http(s)://YOUR-SITE/api/v3`.
70
73
 
71
74
  ### Bitbucket
72
75
 
73
76
  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`.
77
+ Just provide your token info in `bitbucket_username:app_password` format:
78
+
79
+ epr -p bitbucket -t bitbucket_username:app_password user/repo1
75
80
 
76
81
  ### GitLab
77
82
 
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.1"
12
+ VERSION = "0.3.6"
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 "..."
@@ -213,9 +226,16 @@ def gitlab(user, repo)
213
226
  item.title,
214
227
  item.state,
215
228
  localtime(item.created_at),
216
- localtime(item.updated_at),
217
- item.web_url
229
+ localtime(item.updated_at)
218
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
219
239
  end
220
240
  end
221
241
 
@@ -224,13 +244,14 @@ end
224
244
 
225
245
  def export_repos(argv)
226
246
  rows = []
227
- rows << %w[Repository Type # User Title State Created Updated URL]
247
+ rows << %w[Repository Type # User Title State Created Updated Merged URL]
228
248
  rows[-1].insert(4, "Body") if $body
229
249
 
230
250
  repos = parse_repos(argv)
231
251
  repos.each do |user, repo|
232
252
  case $provider
233
253
  when "github"
254
+ abort "milestone filtering can only be used with issues" if $milestone && $export == EXPORT_PRS
234
255
  rows.concat(github(user, repo))
235
256
  when "gitlab"
236
257
  rows.concat(gitlab(user, repo))
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.1
4
+ version: 0.3.6
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-28 00:00:00.000000000 Z
11
+ date: 2021-04-28 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
@@ -89,9 +89,9 @@ require_paths:
89
89
  - lib
90
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ">="
92
+ - - "<"
93
93
  - !ruby/object:Gem::Version
94
- version: '0'
94
+ version: '3'
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ">="
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.7.3
102
+ rubygems_version: 2.7.6
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Export pull requests and issues to a CSV file.