Last active
August 29, 2015 14:10
-
-
Save ziadoz/85a5b9941e21a8419448 to your computer and use it in GitHub Desktop.
Reset Mecurial and Git Repositories
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 | |
Dir.glob("~/Projects/**").each do |dir| | |
next unless File.directory?(dir) | |
is_hg = File.directory?(File.join(dir, '.hg')) | |
is_git = File.directory?(File.join(dir, '.git')) | |
puts "Fixing " + File.basename(dir) | |
Dir.chdir(dir) | |
if is_hg | |
system "hg revert --all --no-backup" | |
system "hg pull -u" | |
elsif is_git | |
system "git reset --hard" | |
system "git pull" | |
else | |
puts "Skipped" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment