Subject: | If someting wrong with hg, Mercurial::Check continues |
I have line "[Mercurial::Check]" in my dist.ini. This plugin runs "hg" in order to check if there are any changed and non-yet-committed files. However, in case of any troubles, for example: "hg" command is not available, or no ".hg" directory found, error message it printed to the screen, but execution continues. Such behavior is not acceptable.
Reason for such behaviour is using backtics: `hg branch`, `hg status`.
I would recommend using IPC::System::Simple, capture() instead. This plugin already has dependency on IPC::System::Simple, so no new dependecies will be introduced.
Patch:
--- lib/Dist/Zilla/Plugin/Mercurial/Check.pm.ORIG 2015-06-12 13:20:12.000000000 +0300
+++ lib/Dist/Zilla/Plugin/Mercurial/Check.pm 2015-06-12 13:20:37.807547646 +0300
@@ -4,16 +4,17 @@
use warnings;
use Moose;
+use IPC::System::Simple 'capture';
with 'Dist::Zilla::Role::BeforeRelease';
sub before_release {
my $self = shift;
- my $branch = `hg branch`;
+ my $branch = capture( 'hg', 'branch' );
chomp $branch;
- if ( my @output = `hg status` ) {
+ if ( my @output = capture( 'hg', 'status' ) ) {
my $errmsg
= "This branch ($branch) has some files that are not yet committed:\n"
. join q{}, map {"\t$_"} @output;