Skip to content

Commit a25781f

Browse files
committed
git-all: use pty+find so results start appearing immediately
1 parent 0ce5291 commit a25781f

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

git-all

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Report the status of all Git repositories within a directory tree.
44

5+
require 'pty'
56
require 'main'
67
require 'git'
78

@@ -140,32 +141,19 @@ Main {
140141

141142
def run
142143
$params = params
143-
$params[:dir].values.each do |dir|
144-
print 'Looking for Git repositories'
145-
if dir == '.'
146-
print '...'
147-
else
148-
print " in #{dir} ..."
149-
end
150-
151-
first = true
152-
seen = Set.new
144+
seen = Set.new
145+
cmd = "find -H #{$params[:dir].values * ' '} -name .git"
153146

154-
# Recursively search for .git directories, following symlinks once
155-
Dir.glob File.join(dir, '**{,/*/**}/.git') do |path|
156-
next if seen.include? path
147+
PTY.spawn cmd do |stdin, stdout, pid|
148+
stdin.each do |path|
149+
next if seen.include? path # never process the same path twice
157150
seen << path
158151

159-
if first
160-
puts 'done'
161-
first = false
162-
end
163-
164152
begin
165153
GitUpdate.report File.dirname(path)
166154
rescue => ex
167155
GitUpdate.top_ten('FAILED', path, [ex.message] + ex.backtrace,
168-
false, '#')
156+
false, '#')
169157
end
170158
end
171159
end

0 commit comments

Comments
 (0)