zz-export-pull-requests 0.3.12 → 0.3.17
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.
- checksums.yaml +4 -4
- data/bin/epr +13 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b50ba3a1501bbe7be4a6c373d5ad252882cd68e1cdfc9750fb3c33be247e61cb
|
4
|
+
data.tar.gz: 34a39672fda231758549b9d73c874a3d82b0654f0de14e7d62435b4f4a56facb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8970282ec36f3891e1d03911139433289877e192bcee1aa90e4315577a0bf7f1fa8f4d7199221e2b54b049493f6b18040862ee896629536ee6231d6c803377b
|
7
|
+
data.tar.gz: b105e4e5c0180ad62ed8628df56d0b194a0f3682d7631e228661d35e1c9fc25633d2cb72860460c7551953a5fc53777f1c594ad1eb085688615c6967a1bdfca6
|
data/bin/epr
CHANGED
@@ -10,7 +10,7 @@ require "github_api"
|
|
10
10
|
require "gitlab"
|
11
11
|
require "bitbucket_rest_api"
|
12
12
|
|
13
|
-
VERSION = "0.3.
|
13
|
+
VERSION = "0.3.17"
|
14
14
|
SERVICES = %w[github gitlab bitbucket]
|
15
15
|
GIT_CONFIGS = %w[epr.token github.oauth-token]
|
16
16
|
|
@@ -29,7 +29,7 @@ BITBUCKET_RATE_LIMIT = 950 # actually, it's 1000 - we play safe here
|
|
29
29
|
# Data will persist in Redis DB/server until we shut it down.
|
30
30
|
# Docs: https://www.rubydoc.info/github/redis/redis-rb/master/frames
|
31
31
|
# Read: https://www.mikeperham.com/2015/09/24/storing-data-with-redis/#databases
|
32
|
-
$redisLogger = Logger.new(
|
32
|
+
$redisLogger = Logger.new(STDERR)
|
33
33
|
$redisLogger.formatter = proc {|severity, datetime, progname, msg|
|
34
34
|
"[#{datetime.strftime('%d/%m/%Y %H:%M:%S')}] EPR-#{severity} - #{msg}\n"
|
35
35
|
}
|
@@ -93,20 +93,25 @@ end
|
|
93
93
|
|
94
94
|
def sleep_if_limit_reached
|
95
95
|
executions = $redis.get("bb-executed").to_i
|
96
|
-
$redisLogger.info("We have called the API for #{executions} times")
|
97
|
-
|
98
96
|
if executions >= BITBUCKET_RATE_LIMIT
|
99
97
|
now = Time.now
|
100
|
-
now_formatted = now.strftime("%I:%M:%S")
|
101
98
|
one_hour = 1*60*60
|
102
99
|
later = now + one_hour
|
103
100
|
later_formatted = later.strftime("%I:%M:%S")
|
104
|
-
|
101
|
+
if ENV['SHOW_LOGS']
|
102
|
+
$redisLogger.info("Rate limit reached. Will pause for an hour and will resume at #{later_formatted}.")
|
103
|
+
end
|
105
104
|
sleep one_hour
|
106
105
|
$redis.set("bb-executed", 0)
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
109
|
+
def check_api_rate_limit
|
110
|
+
executions = $redis.get("bb-executed").to_i
|
111
|
+
$redisLogger.info("We have called the API for #{executions} times") if ENV['SHOW_LOGS']
|
112
|
+
sleep_if_limit_reached
|
113
|
+
end
|
114
|
+
|
110
115
|
def bitbucket(user, repo)
|
111
116
|
# TODO: make sure no need to translate any states
|
112
117
|
# https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests
|
@@ -125,7 +130,7 @@ def bitbucket(user, repo)
|
|
125
130
|
|
126
131
|
loop do
|
127
132
|
page += 1
|
128
|
-
|
133
|
+
check_api_rate_limit
|
129
134
|
|
130
135
|
prs = $bitbucket.repos.pull_request.all(user, repo, :page => page, :state => $filter.upcase)
|
131
136
|
prs["values"].each do |pr|
|
@@ -170,7 +175,7 @@ def bitbucket(user, repo)
|
|
170
175
|
comment_page = 0
|
171
176
|
loop do
|
172
177
|
comment_page += 1
|
173
|
-
|
178
|
+
check_api_rate_limit
|
174
179
|
|
175
180
|
comments = $bitbucket.repos.pull_request.comments(user, repo, pr.id, :page => comment_page)
|
176
181
|
comments["values"].each do |comment|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zz-export-pull-requests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zulhilmi Zainudin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github_api
|