Created
August 1, 2011 16:20
-
-
Save troter/1118448 to your computer and use it in GitHub Desktop.
update any repositories.
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
#!/bin/bash | |
[ -d .git ] && git pull | |
[ -d .hg ] && hg pull -u | |
[ -d .svn ] && svn update | |
[ -d .bzr ] && bzr update |
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
#!/usr/bin/env ruby | |
# -*- coding:utf-8 -*- | |
require 'pathname' | |
class Pathname | |
@@vcs_update_command_table = { | |
'.git' => 'git pull', | |
'.hg' => 'hg pull -u', | |
'.svn' => 'svn up', | |
'.bzr' => 'bzr up', | |
} | |
def repo?(metadata) | |
self.directory? && self.children.any? {|d| File.basename(d) == metadata } | |
end | |
def update() | |
Dir::chdir(self) do | |
p = Pathname::pwd() | |
@@vcs_update_command_table.each do |metadata, command| | |
next unless p.repo?(metadata) | |
puts "UPDATE \"#{p}\"" | |
system(command) | |
end | |
end | |
end | |
end | |
dir = ARGV.shift || '.' | |
Pathname.new(dir).each_child do |p| | |
next unless p.directory? | |
p.update | |
end |
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
#!/bin/bash | |
for i in *; do [ -d $i ] && (echo -- $i; cd $i; update); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment