Created
January 30, 2012 00:09
-
-
Save oleander/1701491 to your computer and use it in GitHub Desktop.
Move slug projects to it's own folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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