Created
June 5, 2015 03:41
-
-
Save kaikoga/937c15408d5aabf51a52 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
TEMP_BRANCH_NAMES = ["🍣", "🍤", "🍖", "🍕", "🍺", "🍷"] | |
local_branches = `git branch --list`.force_encoding('utf-8'). | |
gsub(/^\* /, ''). | |
split("\n"). | |
map(&:strip) | |
if ARGV.include? '-d' | |
temp_branches = local_branches.select{|b|TEMP_BRANCH_NAMES.any?{|t|b.index(t) == 0}} | |
temp_branches.each{|name|`git branch -d #{name}`} | |
exit 0 | |
elsif ARGV.include? '-DDD' | |
temp_branches = local_branches.select{|b|TEMP_BRANCH_NAMES.any?{|t|b.index(t) == 0}} | |
temp_branches.each{|name|`git branch -D #{name}`} | |
exit 0 | |
end | |
temp_branch_names = TEMP_BRANCH_NAMES | |
while true | |
(temp_branch_names - local_branches).each do |name| | |
`git checkout -b #{name}` | |
exit 0 | |
end | |
temp_branch_names = temp_branch_names.zip(TEMP_BRANCH_NAMES).map(&:join) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment