Skip to content

Instantly share code, notes, and snippets.

@arfon
Created May 17, 2020 12:28
Show Gist options
  • Save arfon/8c8990d5fb9501b302502ac5e2072b66 to your computer and use it in GitHub Desktop.
Save arfon/8c8990d5fb9501b302502ac5e2072b66 to your computer and use it in GitHub Desktop.
GitHub repo cleanup
require 'octokit'
GH_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxx"
GITHUB = Octokit::Client.new(:auto_paginate => true, :access_token => GH_TOKEN)
repositories = GITHUB.repositories('arfon')
puts "Working with #{repositories.size} repositories"
repositories.each do |r|
next unless r.fork?
print "What shall I do with #{r.full_name} (K for keep or D for delete):"
action = gets
if action.strip == "D"
puts "Deleting #{r.full_name}"
GITHUB.delete_repository(r.full_name)
elsif action.strip == "K"
puts "Keeping #{r.full_name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment