Skip to content

Commit

Permalink
FIXED : Invalid tar file on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jalilnejad committed Aug 25, 2010
1 parent 62c8aae commit 4174773
Showing 1 changed file with 48 additions and 17 deletions.
65 changes: 48 additions & 17 deletions lib/grit/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,39 @@ def run(prefix, cmd, postfix, options, args)

def sh(command)
ret, err = '', ''
Open3.popen3(command) do |_, stdout, stderr|
Timeout.timeout(self.class.git_timeout) do
while tmp = stdout.read(1024)
ret += tmp
if (@bytes_read += tmp.size) > self.class.git_max_size
bytes = @bytes_read
@bytes_read = 0
raise GitTimeout.new(command, bytes)
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin|cygwin/
Open3.popen3(command, 'b') do |_, stdout, stderr|
Timeout.timeout(self.class.git_timeout) do
while tmp = stdout.read(1024)
ret += tmp
if (@bytes_read += tmp.size) > self.class.git_max_size
bytes = @bytes_read
@bytes_read = 0
raise GitTimeout.new(command, bytes)
end
end
end

while tmp = stderr.read(1024)
err += tmp
end
end
else
Open3.popen3(command) do |_, stdout, stderr|
Timeout.timeout(self.class.git_timeout) do
while tmp = stdout.read(1024)
ret += tmp
if (@bytes_read += tmp.size) > self.class.git_max_size
bytes = @bytes_read
@bytes_read = 0
raise GitTimeout.new(command, bytes)
end
end
end

while tmp = stderr.read(1024)
err += tmp
while tmp = stderr.read(1024)
err += tmp
end
end
end
[ret, err]
Expand All @@ -275,13 +294,25 @@ def sh(command)

def wild_sh(command)
ret, err = '', ''
Open3.popen3(command) do |_, stdout, stderr|
while tmp = stdout.read(1024)
ret += tmp
if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin|cygwin/
Open3.popen3(command, 'b') do |_, stdout, stderr|
while tmp = stdout.read(1024)
ret += tmp
end

while tmp = stderr.read(1024)
err += tmp
end
end
else
Open3.popen3(command) do |_, stdout, stderr|
while tmp = stdout.read(1024)
ret += tmp
end

while tmp = stderr.read(1024)
err += tmp
while tmp = stderr.read(1024)
err += tmp
end
end
end
[ret, err]
Expand All @@ -302,7 +333,7 @@ def transform_options(options)
# ignore
else
val = options.delete(opt)
args << "-#{opt.to_s} '#{e(val)}'"
args << "-#{opt.to_s} \"#{e(val)}\""
end
else
if options[opt] == true
Expand All @@ -311,7 +342,7 @@ def transform_options(options)
# ignore
else
val = options.delete(opt)
args << "--#{opt.to_s.gsub(/_/, '-')}='#{e(val)}'"
args << "--#{opt.to_s.gsub(/_/, '-')}=\"#{e(val)}\""
end
end
end
Expand Down

0 comments on commit 4174773

Please sign in to comment.