zz-export-pull-requests 0.3.14 → 0.3.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/epr +10 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de96b36aca31b822e84ccecae880661cf195490d51c4c2179ec728d8cff2e29a
4
- data.tar.gz: a80cc917dc3f7223ad2a11012e0c8438e07192a69bb7a723b1ab3b1c403020b7
3
+ metadata.gz: 471d1c3557b3f0a5494f00d8077a93d21b5ed7132172fdc34e43931e35ad27b6
4
+ data.tar.gz: f5a3eb11e8bd64a6a2f9f78972dc7bb26fd1acd02810def01b9b5fb59dc29355
5
5
  SHA512:
6
- metadata.gz: afa41b1d13284145982e6de17470762c997b8db2d0b392643dde5d34c57aa36bd5cf8c52fc401a1f6e892fe65ec10255abb8d075662b8fd907909180570268b4
7
- data.tar.gz: 0c9ca291ab505c0e4a5cda68ebf1277cb6931c671abe0514ce6b7bd452a520a6896503fcc426c6118c643062b2c81bb309049222b3d9bf2f5401eaca983e1a21
6
+ metadata.gz: b897f497835022516754f1ab46e6e006240e0f967a5ca331912076bed9edaf1d1c9fdda5ac88c9dd9eb5ffb680ae42b707057d3e2058f80a4081d47bda253f1c
7
+ data.tar.gz: 850734a2562ef96506cb397c1cd2f2fd703813a94cd57c567887d29821725ccd1b8607801576ab4a712810fa8e5abff0fc10fb255cc92f14059c10178db35de4
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.14"
13
+ VERSION = "0.3.15"
14
14
  SERVICES = %w[github gitlab bitbucket]
15
15
  GIT_CONFIGS = %w[epr.token github.oauth-token]
16
16
 
@@ -93,8 +93,6 @@ 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") if ENV['SHOW_LOGS']
97
-
98
96
  if executions >= BITBUCKET_RATE_LIMIT
99
97
  now = Time.now
100
98
  now_formatted = now.strftime("%I:%M:%S")
@@ -109,6 +107,12 @@ def sleep_if_limit_reached
109
107
  end
110
108
  end
111
109
 
110
+ def check_api_rate_limit
111
+ executions = $redis.get("bb-executed").to_i
112
+ $redisLogger.info("We have called the API for #{executions} times") if ENV['SHOW_LOGS']
113
+ sleep_if_limit_reached
114
+ end
115
+
112
116
  def bitbucket(user, repo)
113
117
  # TODO: make sure no need to translate any states
114
118
  # https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/pullrequests
@@ -127,7 +131,7 @@ def bitbucket(user, repo)
127
131
 
128
132
  loop do
129
133
  page += 1
130
- sleep_if_limit_reached
134
+ check_api_rate_limit
131
135
 
132
136
  prs = $bitbucket.repos.pull_request.all(user, repo, :page => page, :state => $filter.upcase)
133
137
  prs["values"].each do |pr|
@@ -165,14 +169,14 @@ def bitbucket(user, repo)
165
169
 
166
170
  loop do
167
171
  pr_page += 1
168
- sleep_if_limit_reached
172
+ check_api_rate_limit
169
173
  prs = $bitbucket.repos.pull_request.all(user, repo, :page => pr_page, :state => $filter.upcase)
170
174
 
171
175
  prs["values"].each do |pr|
172
176
  comment_page = 0
173
177
  loop do
174
178
  comment_page += 1
175
- sleep_if_limit_reached
179
+ check_api_rate_limit
176
180
 
177
181
  comments = $bitbucket.repos.pull_request.comments(user, repo, pr.id, :page => comment_page)
178
182
  comments["values"].each do |comment|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zz-export-pull-requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.14
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulhilmi Zainudin