Skip to content

Instantly share code, notes, and snippets.

@oleander
Created January 30, 2012 00:09
Show Gist options
  • Save oleander/1701491 to your computer and use it in GitHub Desktop.
Save oleander/1701491 to your computer and use it in GitHub Desktop.
Move slug projects to it's own folder
require "colorize"
name = "Linus Oleander"
to = "Slug"
puts "To '#{to}' folder, match on '#{name}'?".yellow
abort("Bye!") unless $stdin.gets =~ /y/
`ls`.split(/\s+/).each do |media|
next if not File.directory?(media) or media == to
gitish = `cd '#{media}' && du | grep '.git$'`.split(" ").map do |git|
next unless git.match(/\.git/)
git_project = File.join(media, git.gsub(/^\.\//, "")).gsub(/\.git$/, "")
!! `cd '#{git_project}' && git shortlog -s`.match(/#{name}/)
end.reject(&:nil?)
if gitish.count > 0 not gitish.any?
puts `mv -vn '#{media}' #{to}`.green
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment