Rewrite hg+ script

This commit is contained in:
Ev Bogdanov 2017-08-16 18:46:25 +03:00
parent ce5b9c0d82
commit 6feacfe8ee
2 changed files with 10 additions and 37 deletions

View file

@ -1,8 +1,7 @@
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
echo where is my commit message, bro?
if [ $# -eq 0 ]; then
echo 'Where is my commit message, bro?'
exit 1
fi

42
bin/hg+
View file

@ -1,36 +1,10 @@
#!/usr/bin/env perl
#!/usr/bin/env bash
use strict;
use warnings;
use Cwd;
if [ $# -eq 0 ]; then
echo 'Where is my commit message, huh?'
exit 1
fi
die 'please enter commit message' unless @ARGV;
my $msg = join ' ', @ARGV;
my $dir = getcwd();
system "hg --cwd $dir addremove";
system "hg --cwd $dir commit -m '$msg'";
system "hg --cwd $dir push";
my $hgrc = "$dir/.hg/hgrc";
open my $fh, '<', $hgrc
or die "cannot open $hgrc: $!\n";
my $repository;
while (my $line = readline($fh)) {
if ($line =~ m/^bb\.prefix = (.+)$/) {
$repository = $1;
last;
}
}
close $fh;
if ($repository) {
print "\nview commits:\n";
print "$repository/commits/all\n";
}
hg addremove
hg commit -m ''"$*"''
hg push