-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvn-walk
executable file
·68 lines (51 loc) · 1.05 KB
/
svn-walk
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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/ruby -w
require "find"
require "optparse"
require "ostruct"
Options = OpenStruct.new
Options.verbose = 0
OptionParser.new do |opts|
opts.banner = "Usage: svn-walk [options] [<command>]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
if v
Options.verbose += 1
else
Options.verbose = 0
end
end
opts.on("-w", "--walk PATH", "Path to start walking from.") do |v|
Options.walk ||= []
Options.walk << v
end
end.parse!
Cmd = ARGV
unless Options.walk
Options.walk = [ "." ]
end
if Options.verbose > 1
p Options
p Cmd
end
Find.find(*Options.walk) do |path|
puts "? "+path if Options.verbose > 1
next unless FileTest.directory? path
next unless FileTest.directory? path+"/.svn"
begin
if Cmd.empty?
puts path
next
end
cmd = Cmd.dup
cmd.push path
if Options.verbose > 0
puts "= #{cmd.join " "}"
end
system(*cmd)
unless $?.success?
$stderr.write "cmd failed with #{$?} - #{cmd.inspect}"
exit 1
end
ensure
Find.prune
end
end