-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvn-tidy
executable file
·76 lines (61 loc) · 1.18 KB
/
svn-tidy
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
68
69
70
71
72
73
74
75
#!/usr/bin/env ruby
$-w = true
require "find"
require "optparse"
require "ostruct"
Options = OpenStruct.new
Options.verbose = 1
OptionParser.new do |opts|
opts.banner = "Usage: svn-tidy [options] [...]"
opts.on("-x", "--execute <cmd>", "Execute cmd, 'rm -rf' might be useful.") do |c|
Options.cmd = c
end
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
if v
Options.verbose += 1
else
Options.verbose = 0
end
end
end.parse!
ARGV.each do |w|
Options.walk ||= []
Options.walk << w
end
unless Options.walk
Options.walk = [ "." ]
end
if Options.verbose > 1
p Options
p Cmd
end
def dump(path, files)
if path
files.each do |f|
_ = "#{path}/#{f}"
if Options.cmd
system("#{Options.cmd} #{_}")
else
puts _
end
end
end
end
IO.popen("svn --non-interactive --recursive propget svn:ignore #{Options.walk.join ' '}") do |io|
path = nil
files = []
while io.gets
$_.chomp!
next unless $_.length > 0
#p [$_.inspect, path, files]
case $_
when /^([^\s]+) - ([^\s]+)$/
dump(path, files)
path = $1
files = [ $2 ]
else
files << $_
end
end
dump(path, files)
end