1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-02-04 04:37:40 +01:00

update pre-commit script

This commit is contained in:
tateisu 2019-09-30 02:40:12 +09:00
parent 970869550a
commit cb8a8816bc
2 changed files with 49 additions and 1 deletions

View File

@ -6,6 +6,54 @@ use File::Find;
use XML::Simple;
use Data::Dump qw(dump);
sub cmd($){
print "+ ",$_[0],"\n";
my $rv=system $_[0];
if ($? == -1) {
die "failed to execute: $!\n";
}elsif ($? & 127) {
die "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without';
}else {
my $rv = $? >> 8;
$rv and die "child exited with value $rv\n";
}
}
# ワーキングツリーに変更がないことを確認
open(my $fh,"-|","git status --porcelain --branch")
or die "can't check git status. $!";
my @untrackedFiles;
while(<$fh>){
chomp;
if(/^\?\?\s*(\S+)/){
my $path =$1;
next if $path =~ /\.idea|_Emoji/;
push @untrackedFiles,$path
}elsif( /^##\s*(\S+?)(?:\.\.|$)/ ){
my $branch=$1;
print "# branch=$branch\n";
$branch eq 'master'
or die "current branch is not master.\n";
# }else{
# warn "working tree is not clean.\n";
# cmd "git status";
# exit 1;
}
}
close($fh)
or die "can't check git status. $!";
@untrackedFiles and die "forgot git add?\n",map{ "- $_\n"} @untrackedFiles;
my $xml = XML::Simple->new;
my $master_name = "_master";

View File

@ -15,7 +15,6 @@ sub cmd($){
}
}
my $buildFile = 'app/build.gradle';
# ワーキングツリーに変更がないことを確認
open(my $fh,"-|","git status --porcelain --branch")
@ -46,6 +45,7 @@ close($fh)
@untrackedFiles and die "forgot git add?\n",map{ "- $_\n"} @untrackedFiles;
# 現在のバージョン番号を取得
my $buildFile = 'app/build.gradle';
`cat $buildFile` =~ /versionName\s+["']([\d\.]+)["']/
or die "missing versionName in $buildFile\n";
my($tag)="v$1";