ghedo/p5-Dist-Zilla-Plugin-GitHub — pull request #19 by rkitover (2013-01-13 17:43:18+00:00)
Title: wrap $git->rev_parse in a try {} block

When there are no commits, $git->rev_parse will print a bunch of crap to
STDERR, wrapping it in a try block silences it.

E.g.:

rkitover@macmini ~ % cd /tmp
rkitover@macmini /tmp % mkdir foo
rkitover@macmini /tmp % cd foo
rkitover@macmini /tmp/foo % git init
Initialized empty Git repository in /private/tmp/foo/.git/
rkitover@macmini /tmp/foo % touch README
rkitover@macmini /tmp/foo %
rkitover@macmini /tmp/foo % ls
README
rkitover@macmini /tmp/foo % perl -MGit::Wrapper -le 'my $git = Git::Wrapper->new("."); print $git->rev_parse({ symbolic_full_name => 1, abbrev_ref => 1 }, "HEAD")'
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
rkitover@macmini /tmp/foo % perl -MGit::Wrapper -MTry::Tiny -le 'my $git = Git::Wrapper->new("."); try { print $git->rev_parse({ symbolic_full_name => 1, abbrev_ref => 1 }, "HEAD") };'
rkitover@macmini /tmp/foo %