File tree 2 files changed +29
-10
lines changed 2 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -118,8 +118,16 @@ def chdir # :yields: the Git::Path
118
118
end
119
119
120
120
# returns the repository size in bytes
121
- def repo_size
122
- return IO . popen ( "du -s" , { :chdir => repo . path } ) . read . chomp . split . first . to_i
121
+ if ( RUBY_VERSION . to_f < 1.9 )
122
+ def repo_size
123
+ Dir . chdir ( repo . path ) do
124
+ return IO . popen ( "du -s" ) . read . chomp . split . first . to_i
125
+ end
126
+ end
127
+ else
128
+ def repo_size
129
+ return IO . popen ( "du -s" , { :chdir => repo . path } ) . read . chomp . split . first . to_i
130
+ end
123
131
end
124
132
125
133
#g.config('user.name', 'Scott Chacon') # sets value
Original file line number Diff line number Diff line change @@ -806,16 +806,27 @@ def log_path_options(opts)
806
806
arr_opts
807
807
end
808
808
809
- def run_command ( git_cmd , chdir = nil , &block )
810
- commands = [ git_cmd ]
811
- commands << { :chdir => chdir } unless chdir . nil?
812
- if block_given?
813
- retval = IO . popen ( *commands , &block )
814
- return retval , $?
809
+ # run_command
810
+ if ( RUBY_VERSION . to_f < 1.9 )
811
+ # in Ruby 1.8 we just have to run inside Dir.chdir. No getting around it
812
+ def run_command ( git_cmd , chdir = nil , &block )
813
+ Dir . chdir ( chdir || Dir . getwd ) do
814
+ return IO . popen ( git_cmd , &block ) , $? if block_given?
815
+ return `#{ git_cmd } ` . chomp , $?
816
+ end
815
817
end
816
- out , process_status = Open3 . capture2 ( *commands )
818
+ else
819
+ def run_command ( git_cmd , chdir = nil , &block )
820
+ commands = [ git_cmd ]
821
+ commands << { :chdir => chdir } unless chdir . nil?
822
+ if block_given?
823
+ retval = IO . popen ( *commands , &block )
824
+ return retval , $?
825
+ end
826
+ out , process_status = Open3 . capture2 ( *commands )
817
827
818
- return out . chomp , process_status
828
+ return out . chomp , process_status
829
+ end
819
830
end
820
831
821
832
def escape ( s )
You can’t perform that action at this time.
0 commit comments