Skip to content

Instantly share code, notes, and snippets.

@carlwoodward
Created November 22, 2013 04:51
Show Gist options
  • Save carlwoodward/7595021 to your computer and use it in GitHub Desktop.
Save carlwoodward/7595021 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "date"
class Branch < Struct.new(:name, :date)
end
branches = `git branch -a`.split("\n").map do |branch_name|
unless branch_name.include?("*") || branch_name.include?("->")
has_activity = `git log --abbrev-commit --date=short -1 #{branch_name}`
last_activity = `echo "#{has_activity}" | grep Date: | sed 's/Date: //'`
Branch.new branch_name, Date.parse(last_activity)
end
end.compact
branches.sort_by(&:date).each do |branch|
puts "#{branch.name} last activity was \033[1;31m#{branch.date.to_s}\033[0m"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment