Please rate my scripts.

Hans Fugal hans at
Mon Apr 14 10:43:34 MDT 2008

Comments on the Ruby script:

 > include FileTest

AFAICT that's just for one call - exists?(), which I think would be 
clearer as File.exists?() anyway.

 > ARGC = ARGV.length
 > if (ARGC == 0) or ((ARGC == 1) and not exists?(ARGV[0]))
 >     treeish = ARGV[0] || 'master'

I might rewrite that as

first = ARGV[0]
if first.nil? or not File.exist?(first)
   treeish = first || 'master'

 >    cmd = "git diff --name-only '#{treeish}'"
 >    files = IO.popen( cmd ).readlines

Quoting nightmare. Unfortunately there's not a particularly easy and 
terse solution. See

It could be adapted to this use case too. Oh, and you forgot(?) to close 
your open file handle.

Actually, quoting nightmare aside I might do it this way:

files = `git diff --name-only '#{treeish}'`.split('\n')
for file in files


Hans Fugal ;

There's nothing remarkable about it. All one has to do is hit the
right keys at the right time and the instrument plays itself.
     -- Johann Sebastian Bach

More information about the PLUG mailing list