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

mainブランチだとpre-commitチェックで止まる用にする

This commit is contained in:
tateisu 2021-07-04 01:16:10 +09:00
parent 272e24a90d
commit c93854b9b5

View File

@ -6,6 +6,7 @@ use File::Find;
use XML::Simple; use XML::Simple;
use Data::Dump qw(dump); use Data::Dump qw(dump);
use utf8; use utf8;
use feature qw(say);
binmode $_ for \*STDOUT,\*STDERR; binmode $_ for \*STDOUT,\*STDERR;
@ -30,6 +31,7 @@ open(my $fh,"-|","git status --porcelain --branch")
or die "can't check git status. $!"; or die "can't check git status. $!";
my @untrackedFiles; my @untrackedFiles;
my $branch;
while(<$fh>){ while(<$fh>){
s/[\x0d\x0a]+//; s/[\x0d\x0a]+//;
if(/^\?\?\s*(\S+)/){ if(/^\?\?\s*(\S+)/){
@ -37,12 +39,7 @@ while(<$fh>){
next if $path =~ /\.idea|_Emoji/; next if $path =~ /\.idea|_Emoji/;
push @untrackedFiles,$path push @untrackedFiles,$path
}elsif( /^##\s*(\S+?)(?:\.\.|$)/ ){ }elsif( /^##\s*(\S+?)(?:\.\.|$)/ ){
my $branch=$1; $branch=$1;
print "# branch=$branch\n";
if($preCommit){
# mainブランチに直接コミットすることはなくなった
$branch eq 'main' and warn "!!!! current branch is main. Direct commits and pushes are prohibited. !!!!\n";
}
# }else{ # }else{
# warn "working tree is not clean.\n"; # warn "working tree is not clean.\n";
# cmd "git status"; # cmd "git status";
@ -154,6 +151,13 @@ print "(total)string resource count=$nameCount\n";
$hasError and die "please fix error(s).\n"; $hasError and die "please fix error(s).\n";
# ブランチがmainなら直接コミットさせない
print "# branch=$branch\n";
if($preCommit){
# mainブランチに直接コミットすることはなくなった
$branch eq 'main' and die "!!!! current branch is main. Direct commits and pushes are prohibited. !!!!\n";
}
# Weblateの未マージのブランチがあるか調べる # Weblateの未マージのブランチがあるか調べる
system qq(git fetch weblate -q); system qq(git fetch weblate -q);
my @list = `git branch -r --no-merged`; my @list = `git branch -r --no-merged`;