Skip to content

Commit a4569c1

Browse files
committed
Merge pull request github#24 from github/gjtorikian-patch-1
Add the fork_checker.rb
2 parents c8b24ed + 249d6f8 commit a4569c1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

api/ruby/fork_checker.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'octokit.rb'
2+
3+
if ARGV.length != 1
4+
$stderr.puts "Pass in the name of the repository you're interested in checking as an argument, as <owner>/<repo>."
5+
exit 1
6+
end
7+
8+
# !!! DO NOT EVER USE HARD-CODED VALUES IN A REAL APP !!!
9+
# Instead, set and test environment variables, like below
10+
client = Octokit::Client.new(:access_token => ENV['MY_PERSONAL_TOKEN'])
11+
12+
REPO = ARGV[0].to_s
13+
owner = REPO.split("/")[0]
14+
15+
client.forks REPO
16+
forks = client.last_response.data
17+
loop do
18+
last_response = client.last_response
19+
break if last_response.rels[:next].nil?
20+
forks.concat last_response.rels[:next].get.data
21+
end
22+
23+
forks.map{ |f| f[:owner][:login] }.each do |user|
24+
unless client.organization_member?(owner, user)
25+
puts "#{user} forked #{REPO}, but is not a member of #{owner}!"
26+
end
27+
end

0 commit comments

Comments
 (0)