-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitup
executable file
·57 lines (48 loc) · 1.08 KB
/
gitup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/env ruby -w
# Pull remote changes for several directories at once
# if they are git directories.
#
# AUTHOR: Geoffrey Grosenbach
# April 28, 2009
#
# USAGE:
#
# gitup repos/*
require "optparse"
options = {
:recurse => false,
:verbose => false,
}
ARGV.options do |opts|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] [DIRECTORY]"
opts.separator ""
opts.separator "Common Options:"
opts.on( "-h", "--help",
"Show this message." ) do
puts opts
exit
end
opts.on( "-r", "--recurse",
"Recurse into subdirectories, looking for .git" ) do
options[:recurse] = true
end
opts.on( "-v", "--verbose",
"Output extra info." ) do
options[:verbose] = true
end
begin
opts.parse!
rescue
puts opts
exit
end
end
dirs = ARGV.first ? ARGV : [options[:recurse] ? './**/*' : './*']
Dir[*dirs].each do |project|
if File.exist?(File.join(project, '.git'))
puts "== Updating #{project}"
system "cd #{project} && git pull && git --no-pager status"
else
puts "Skipping: #{project}" if options[:verbose]
end
end