Skip to content

Commit

Permalink
not sure why this was never checked in
Browse files Browse the repository at this point in the history
  • Loading branch information
bronson committed Apr 2, 2021
1 parent 2c3a750 commit 06e8540
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions empty-repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env ruby

# Mass delete, just pass the names or full paths of the repos to delete
# and both the github and local repos/* repositories will be deleted.
#
##
# You might need to wait for a few hours between deleting and pushing
# since github has a bug where quickly deleting, creating, and pushing a
# repo with the same name will just result in a resurrection of the old
# repo with the old contents, not an empty one.
#
# Now you can use "FORCE=1 ./scraper 0999" to get around this. It doesn't
# update the script's description but usually that's not needed and it's
# better than waiting for github to fix this bug!


$:.unshift './lib'

require 'bundler'
Bundler.require
require 'github'


scripts = {}

ARGV.each do |name|
name =~ /^repos\/(.*)\.git\/?$/
name = $1 if $1
path = "repos/#{name}.git"

if test ?d, path
scripts[name] = path
else
puts "warning: can't find #{path}"
end
end

github = GitHub.new
scripts.each do |name,path|
github.delete name
end

scripts.each do |name,path|
begin
FileUtils.rm_rf path
puts "deleted #{path}"
rescue Exception => e
puts "could not delete #{path}: #{e}"
end
end

0 comments on commit 06e8540

Please sign in to comment.