Skip to content

Instantly share code, notes, and snippets.

@kaikoga
Created June 5, 2015 03:41
Show Gist options
  • Save kaikoga/937c15408d5aabf51a52 to your computer and use it in GitHub Desktop.
Save kaikoga/937c15408d5aabf51a52 to your computer and use it in GitHub Desktop.
#!/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