Created
June 4, 2010 07:37
-
-
Save aerickson/425107 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
require 'rubygems' | |
require 'grit' | |
require 'active_support' | |
include Grit | |
# | |
# USAGE: dead_branches <path_to_repo> | |
# | |
# AUTHOR: Ben Sandofsky | |
# find all branches that have been merged into master | |
merged_branches = `git branch -a --merged`.split("\n").collect(&:strip) - ["* master"] | |
repo = Repo.new(ARGV[0]) | |
merged_branches.each do |branch| | |
begin | |
last_commit = repo.commits(branch).first | |
last_time = Time.parse last_commit.to_hash['committed_date'] | |
committer = last_commit.to_hash['committer'] | |
# if the branch hasn't changed in 30 days | |
if last_time < 30.days.ago | |
puts "#{branch.sub("remotes/origin/", "")}:\t#{last_time.strftime("%m/%d/%Y")}\t#{committer['name']} #{committer['email']}\t#{last_commit.to_hash['id']}" | |
end | |
rescue | |
puts "Failure on branch: #{branch}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment