Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'octokit'
client = Octokit::Client.new login: 'username', password: 'password'
repos = []
page = 1
loop do
puts "Fetching repositories from page ##{page}"
new_repos = client.organization_repositories('organization',
type: :all,
per_page: 100,
page: page
).map(&:full_name)
repos.concat(new_repos)
if new_repos.count < 100
break
else
page += 1
end
end
puts "Total of repositories: #{repos.count}\n"
repos.each_with_index do |repo, index|
print "Repo #{index + 1}/#{repos.count} - '#{repo}'..."
print "\tRemoving current labels"
client.labels(repo).each do |label|
print '.'
client.delete_label!(repo, label[:name])
end
labels = [
{ name: 'reviewed', color:'207de5' },
{ name: 'staging', color:'fbca04' }
]
print "\tCreating new labels\t"
labels.each do |label|
print '.'
client.add_label(repo, label[:name], label[:color])
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment