Created
January 1, 2012 04:25
-
-
Save brentsimmons/1546249 to your computer and use it in GitHub Desktop.
Find Mercurial repositories and print status
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
#!/usr/bin/env ruby -wKU | |
# Prints the directory names and hg status output for any Mercurial | |
# repositories where hg status returns something non-nil. | |
# | |
# Assumes everything is in a Projects directory in your home folder. | |
# 12/31/2011 Brent Simmons | |
require 'find' | |
require 'open3' | |
homeDirectory = ENV["HOME"] | |
projectsDirectory = homeDirectory + "/Projects" | |
Find.find(projectsDirectory) do |path| | |
if File.basename(path) == '.hg' | |
workingDirectory = File::dirname(path) | |
Dir.chdir(workingDirectory) | |
status = Open3.popen3("hg status")[1].read | |
if status == "" then next end | |
print("\n#{workingDirectory}\n") | |
print status | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment