From 346167ea0bda2346b415c31507905e95faa0b1fd Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 30 Nov 2026 06:55:11 -0500 Subject: hooks/*: replace tab indents with 2 spaces each. --- hooks/commit-msg | 140 +++++++++++++++++++++++++++---------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) (limited to 'hooks/commit-msg') diff --git a/hooks/commit-msg b/hooks/commit-msg index 5482389..0fe306b 100755 --- a/hooks/commit-msg +++ b/hooks/commit-msg @@ -146,7 +146,7 @@ $MAXLEN = 68; "ChangeLog.txt: ", "README: ", "Public www update: ", - "(tag: ", # I'm not sure this actually does anything + "(tag: ", # I'm not sure this actually does anything ); abort("Hook called with no argument.") unless $ARGV[0]; @@ -155,9 +155,9 @@ $msgfile = $ARGV[0]; # get list of directories with changes. for(split /\0/, `git -P diff -z --cached --name-only`) { - my ($cat, $prog, undef) = split /\//, $_, 3; - next unless (defined $cat && defined $prog); - $dirs{"$cat/$prog"}++; + my ($cat, $prog, undef) = split /\//, $_, 3; + next unless (defined $cat && defined $prog); + $dirs{"$cat/$prog"}++; } @dirs = keys %dirs; @@ -171,106 +171,106 @@ chomp for @lines; $msgline = $lines[0]; if(grep { index($msgline, $_) == 0 } @admin_msgs) { - warn "$SELF: Skipping checks due to admin-only commit message.\n"; - exit 0; + warn "$SELF: Skipping checks due to admin-only commit message.\n"; + exit 0; } if(@dirs > 1) { - abort("Aborting due to changes in multiple directories:" . - join("\n ", "", @dirs)); + abort("Aborting due to changes in multiple directories:" . + join("\n ", "", @dirs)); } $lines[0] = fix_message($msgline, $dirs[0]); save_file($msgfile, @lines) if $msgline ne $lines[0]; if(exists($ENV{DRYRUN})) { - warn "$SELF: commit message OK, not committing due to DRYRUN in env.\n"; - exit 1; + warn "$SELF: commit message OK, not committing due to DRYRUN in env.\n"; + exit 1; } exit 0; ################################################################# sub fix_message { - my $msg = shift; - my $catprg = shift; - - my $prefix = "$catprg: "; - my $orig = $msg; - - # v => Updated for version - # v,stuff => Updated for version , stuff - if($msg =~ /^v(?:\s*,\s*(\S.*$))?/) { - my $rest = defined $1 ? ", $1" : ""; - $msg = "Updated for version " . get_ver($catprg) . $rest; - } - - # add prefix only if missing. - if(index($msg, $prefix) != 0) { - if($msg =~ /^(\S+:)(\s)?/) { - my $err = "Commit message has bad prefix:\n" . - " '$1'\n should be:\n '$prefix'"; - if(!defined($2)) { - $err .= "\n Missing space after '$1'"; - } - abort($err); - } - $msg = "$prefix$msg"; - } - - # add a period if there isn't one, and if there's room for one. - if(length($msg) < $MAXLEN && ($msg !~ /.*\.$/)) { - $msg .= "."; - } - - if($msg ne $orig) { - warn < Updated for version + # v,stuff => Updated for version , stuff + if($msg =~ /^v(?:\s*,\s*(\S.*$))?/) { + my $rest = defined $1 ? ", $1" : ""; + $msg = "Updated for version " . get_ver($catprg) . $rest; + } + + # add prefix only if missing. + if(index($msg, $prefix) != 0) { + if($msg =~ /^(\S+:)(\s)?/) { + my $err = "Commit message has bad prefix:\n" . + " '$1'\n should be:\n '$prefix'"; + if(!defined($2)) { + $err .= "\n Missing space after '$1'"; + } + abort($err); + } + $msg = "$prefix$msg"; + } + + # add a period if there isn't one, and if there's room for one. + if(length($msg) < $MAXLEN && ($msg !~ /.*\.$/)) { + $msg .= "."; + } + + if($msg ne $orig) { + warn < $MAXLEN) { - abort("Commit message too long ($l chars, max is $MAXLEN)."); - } + my $l = length $msg; + if($l > $MAXLEN) { + abort("Commit message too long ($l chars, max is $MAXLEN)."); + } - return $msg; + return $msg; } ################################################################# # Saves the commit message file (overwrites the original). sub save_file { - my $file = shift; - open my $f, ">", $file or abort("$file: $!"); - print $f "$_\n" for @_; - close $f; + my $file = shift; + open my $f, ">", $file or abort("$file: $!"); + print $f "$_\n" for @_; + close $f; } ################################################################# # Read VERSION from the .info file, return it. sub get_ver { - my $catprg = shift; - my $prg = $catprg =~ s,.*/,,r; - my $info = "$catprg/$prg.info"; - my $ver; - - open my $f, "<", $info or abort("Missing $info file"); - while(<$f>) { - next unless /^VERSION="([^"]+)"/; - $ver = $1; - last; - } - close $f; - - abort("Can't read VERSION from $info") unless defined $ver; - return $ver; + my $catprg = shift; + my $prg = $catprg =~ s,.*/,,r; + my $info = "$catprg/$prg.info"; + my $ver; + + open my $f, "<", $info or abort("Missing $info file"); + while(<$f>) { + next unless /^VERSION="([^"]+)"/; + $ver = $1; + last; + } + close $f; + + abort("Can't read VERSION from $info") unless defined $ver; + return $ver; } ################################################################# sub abort { - warn "*** $_[0]\n" if $_[0]; - die "$SELF hook: Commit aborted due to bad commit message.\n"; + warn "*** $_[0]\n" if $_[0]; + die "$SELF hook: Commit aborted due to bad commit message.\n"; } -- cgit v1.2.3