Skip to content

Instantly share code, notes, and snippets.

@arfon
Created January 17, 2019 15:55
Show Gist options
  • Save arfon/8d3a9b6b673b0b14e6f807cdfaf28df6 to your computer and use it in GitHub Desktop.
Save arfon/8d3a9b6b673b0b14e6f807cdfaf28df6 to your computer and use it in GitHub Desktop.
GitHub repo cleanup
require 'octokit'
GH_TOKEN = "XXXXXXXXXXXXXXXXXXXXXXXXXX"
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