github_bot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb400bd3151dbb9d477b4150cf7b3e5ebc61b070cfd5597a6d23c816fdc7ca44
4
- data.tar.gz: 1411caee2a3eac409d5c09ee2a0f522e9f56159cd35596fec8e719ab108c57e3
3
+ metadata.gz: 55e5c2085a789f760946a31c8045af4bd6cfbfbddd86a27b6a733d409f20f37e
4
+ data.tar.gz: 91de233efa71c6cd583d9d3a41496e6b01ffd9428aa73afdc0243a9430fa867c
5
5
  SHA512:
6
- metadata.gz: b0aa4c7ca622fd31fbd0bf5ae8aef357389c08ff9098d6e2898570d022423e1b2bb281a65e7b0a0fbfdcd3bcd827210ce4f366788c44fb3660b61aee58ee5a9e
7
- data.tar.gz: 91aa6cecdc0f881ff3a308c3e073083686ff740ecd2ce4d981d7b4a29ddbb5cc60104feb447a9f35f5c67023e88cc3a6a3526a3d68c70fc3527faa7d3ff31f45
6
+ metadata.gz: 06f5dc19cb2f0516277c46ecffce1031f1ac7d5e5e60a2302ed5cc58260926523418ba467c4b147469debf8310d64163f8ea1577a4e71fe5c0762f212f1ef9d6
7
+ data.tar.gz: 1466c3f469110542d78538254e0c489fb256020e0f1a3cea8dc3530a113426a28516dcdaf0031b8ec21718d7217c23d9d15cb177c43438a6e3ffbc693ad44961
@@ -9,7 +9,7 @@ assignees: ''
9
9
 
10
10
  > Before reporting a bug
11
11
  - [ ] Check the bug is reproducible.
12
- - [ ] Search for [existing issues](https://github.com/poloka/github_bot-ruby/issues).
12
+ - [ ] Search for [existing issues](https://github.com/cerner/github_bot-ruby/issues).
13
13
 
14
14
  **Describe the bug**
15
15
  A clear and concise description of what the bug is.
@@ -2,5 +2,5 @@
2
2
  blank_issues_enabled: false
3
3
  contact_links:
4
4
  - name: GitHub Community Support
5
- url: https://github.com/poloka/github_bot-ruby/discussions
5
+ url: https://github.com/cerner/github_bot-ruby/discussions
6
6
  about: Please ask and answer questions and propose new features.
data/Gemfile CHANGED
@@ -16,6 +16,7 @@ gem 'rubocop-performance', '~> 1.8', require: false
16
16
  gem 'rubocop-rake', '~> 0.5', require: false
17
17
  gem 'rubocop-rspec', '~> 2.1', require: false
18
18
  gem 'simplecov', '~> 0.19', require: false
19
+ gem 'timecop', '~> 0.9'
19
20
 
20
21
  # debugging
21
22
  gem 'debase', '~> 0.2.5.beta2'
@@ -135,15 +135,35 @@ module GithubBot
135
135
  # Public: Returns the repository fork URL from the original project with the most
136
136
  # recent updated forked instance first
137
137
  #
138
+ # Utilizing API: https://docs.github.com/en/rest/reference/repos#forks
139
+ # Example: https://api.github.com/repos/octocat/Hello-World/forks?page=1
140
+ #
138
141
  # @return [Array] The array of [String] URLs associated to the forked repositories
139
142
  def repository_fork_urls
140
143
  return @repository_fork_urls if @repository_fork_urls
141
144
 
142
145
  @repository_fork_urls =
143
146
  [].tap do |ar|
144
- json = URI.parse(repository[:forks_url]).open.read
145
- JSON.parse(json).sort_by { |i| Date.parse i['updated_at'] }.reverse_each do |fork|
146
- ar << fork['clone_url']
147
+ # iterate over pages of forks
148
+ page_count = 1
149
+ forks_url = repository[:forks_url]
150
+ loop do
151
+ uri = URI.parse(forks_url)
152
+ new_query_ar = URI.decode_www_form(String(uri.query)) << ['page', page_count]
153
+ uri.query = URI.encode_www_form(new_query_ar)
154
+
155
+ Rails.logger.info "#{self.class}##{__method__} retrieving #{uri}"
156
+
157
+ json = uri.open.read
158
+ json_response = JSON.parse(json)
159
+ break if json_response.empty?
160
+
161
+ # iterate over each fork and capture the clone_url
162
+ json_response.each do |fork|
163
+ ar << fork['clone_url']
164
+ end
165
+
166
+ page_count += 1
147
167
  end
148
168
  end
149
169
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GithubBot
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
 
6
6
  # version module
7
7
  module Version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Howdeshell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-11 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git