Created
June 27, 2012 01:10
-
-
Save joshuaflanagan/3000618 to your computer and use it in GitHub Desktop.
See what's going on in your .git folder when you perform git commands
This file contains hidden or 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
# I used this to monitor changes to the .git folder during | |
# my Austin on Rails lightning talk on Understanding Git. | |
# | |
# I ignore any changes to the .git/logs folder, because they are | |
# noisy and don't add a lot to understanding. | |
# If you want "the whole truth", remove the :ignore parameter below. | |
# | |
# ruby listen.rb <path to .git folder> | |
# | |
# gem install listen # its the foundation of Guard | |
require 'listen' | |
path_to_watch = ARGV[0] || '.' | |
last_change = Time.now | |
Listen.to(path_to_watch, | |
:relative_paths => true, | |
:ignore => /logs\//) do |modified, added, removed| | |
# cheap way to add some separation between output from git commands | |
latest = Time.now | |
if (latest - last_change > 1) | |
last_change = latest | |
puts "\n\n" | |
end | |
modified.each{|m| puts "\e[33mCHANGED\e[0m #{m}" } | |
added.each{|m| puts "\e[32m ADDED\e[0m #{m}" } | |
removed.each{|m| puts "\e[31mREMOVED\e[0m #{m}" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 thats cool