jqr/heroku_san

HerokuSan::Git doesn't handle all git errors

jturkel opened this issue · 0 comments

There are several methods in HerokuSan::Git that either silently ignore git errors or throw unexpected exceptions. All examples assume the following object:

>> git = Object.new.extend(HerokuSan::Git)
  1. If git command in git_active_branch fails a NoMethodError is thrown
>> Dir.chdir("/tmp")
>> git.git_active_branch
NoMethodError: undefined method `split' for nil:NilClass
    from /Users/jturkel/.rvm/gems/ruby-2.0.0-p481@dandelion/gems/heroku_san-4.3.2/lib/heroku_san/git.rb:15:in `git_active_branch'
  1. If the git command fails in git_rev_parse the first line of the ref arg is returned:
>> git.git_rev_parse("bad")
"bad"
  1. If the git command fails in git_revision nil is returned:
>> git.git_revision('bad-repo')
nil
  1. If the git command fails in git_named_rev an empty string is returned:
>> git.git_named_rev('bad-ref')
""

Note in all cases the git error is echoed to stderr but scripts using this module will continue happily running when they should fail.