Skip to content

Instantly share code, notes, and snippets.

@troter
Created August 1, 2011 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save troter/1118448 to your computer and use it in GitHub Desktop.
Save troter/1118448 to your computer and use it in GitHub Desktop.
update any repositories.
#!/bin/bash
[ -d .git ] && git pull
[ -d .hg ] && hg pull -u
[ -d .svn ] && svn update
[ -d .bzr ] && bzr update
#!/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
#!/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