HerokuSan::Git doesn't handle all git errors
jturkel opened this issue · 0 comments
jturkel commented
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)
- If git command in
git_active_branch
fails aNoMethodError
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'
- If the git command fails in
git_rev_parse
the first line of theref
arg is returned:
>> git.git_rev_parse("bad")
"bad"
- If the git command fails in
git_revision
nil
is returned:
>> git.git_revision('bad-repo')
nil
- 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.