Sha256: d6148bbb8375a433d6080dff5c3c9ddafecca83520872ad125457f0a23c5ea78
Contents?: true
Size: 1012 Bytes
Versions: 10
Compression:
Stored size: 1012 Bytes
Contents
#!/usr/bin/env ruby #prune branches that have been merged into master from the repo #usage -r --remote to prune remote branches require File.join(File.dirname(__FILE__), '..', 'lib', 'socialcast-git-extensions.rb') include Socialcast remote = ARGV.delete("--remote") || ARGV.delete("-r") run_cmd "git checkout master" run_cmd "git pull" def each_branch(options = {}, &block) reserved_branches = %w{ HEAD master last_known_good_master staging last_known_good_staging next_release last_known_good_next_release } args = [] args << '-r' if options[:remote] args << '--merged' branches = `git branch #{args.join(' ')}`.split("\n") branches.each do |branch| branch = branch.gsub(/\*/, '').strip.split(' ').first branch = branch.split('/').last if options[:remote] yield(branch) unless reserved_branches.include?(branch) end end each_branch do |branch| run_cmd "git branch -d #{branch}" end if remote each_branch :remote => true do |branch| run_cmd "grb rm #{branch}" end end
Version data entries
10 entries across 10 versions & 1 rubygems