diff options
author | krion <krion@FreeBSD.org> | 2004-05-26 16:57:06 +0800 |
---|---|---|
committer | krion <krion@FreeBSD.org> | 2004-05-26 16:57:06 +0800 |
commit | 645f7f9a7c9fdbf0084690574767ef8367f57dd9 (patch) | |
tree | b890b4372372ea7a2f47f17907571a066eefd6b4 /CVSROOT | |
parent | 7a9cfdcb93edc826d48d1ac97e8b6cb96b98111c (diff) | |
download | freebsd-ports-gnome-645f7f9a7c9fdbf0084690574767ef8367f57dd9.tar.gz freebsd-ports-gnome-645f7f9a7c9fdbf0084690574767ef8367f57dd9.tar.zst freebsd-ports-gnome-645f7f9a7c9fdbf0084690574767ef8367f57dd9.zip |
- Check whether commits are approved by portmgr during the
portfreeze
Note: that is not final step to activate it, changes to
existing scripts will follow later.
Discussed with: kuriyama
Diffstat (limited to 'CVSROOT')
-rwxr-xr-x | CVSROOT/approvecheck | 115 | ||||
-rw-r--r-- | CVSROOT/approvers | 22 | ||||
-rw-r--r-- | CVSROOT/checkoutlist | 3 | ||||
-rwxr-xr-x | CVSROOT/verifymsgcheck | 20 |
4 files changed, 160 insertions, 0 deletions
diff --git a/CVSROOT/approvecheck b/CVSROOT/approvecheck new file mode 100755 index 000000000000..8d063f676295 --- /dev/null +++ b/CVSROOT/approvecheck @@ -0,0 +1,115 @@ +#!/usr/bin/perl -w +# +# $FreeBSD$ + +use strict; +use lib $ENV{CVSROOT}; +use CVSROOT::cfg; +my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!"; +my $debug = $cfg::DEBUG; + +my $BASE_FN = "$cfg::TMPDIR/$cfg::FILE_PREFIX"; +my $FILES_FILE = "$BASE_FN.files"; + +print "$$: pgrp: ", getpgrp(), "\n" if ($debug); +print "$$: committer: ", $cfg::COMMITTER, "\n" if ($debug); + +foreach (@ARGV) { + print "$$: args: $_\n" if ($debug); +} + +my $logfile = $ARGV[0]; +my $log = ""; +if (-r $logfile) { + open(H, "<$logfile") or die; + foreach (<H>) { + print "$$: log: $_" if ($debug); + $log .= $_; + } + close(H); +} + +if (-r $FILES_FILE and open(FILES, $FILES_FILE)) { + my %tag; + while (<FILES>) { + chomp; + my ($tag, $file) = split(/\t/, $_, 2); + print "$$: files_file: tag=$tag, file=$file\n" if ($debug); + push @{$tag{$tag}}, $file; + } + close(FILES); + + if (check_approvers($log, %tag)) { + unlink $FILES_FILE; + exit 1; + } +} +exit 0; + +# ============================================================ +sub read_approvers { + my @Approvers; + my $approvers = "$CVSROOT/CVSROOT/approvers"; + if (-r $approvers) { + print "$$: Read $approvers\n" if ($debug); + open(APP, "<$approvers") or return; + while (<APP>) { + chomp; + next if (/^#/); + my ($mod, $tag, $rev) = split(/\t+/, $_, 3); + if ($rev) { + push @Approvers, { mod => $mod, + tag => $tag, + app => $rev }; + } + } + close(APP); + } + @Approvers; +} + +sub check_approvers { + my ($log, %files) = @_; + my %tag; + my @Approvers = &read_approvers(); + foreach my $t (keys %files) { + foreach (@{$files{$t}}) { + $tag{$t}->{$_}++; + } + } + foreach my $r (@Approvers) { + printf "$$: checking: %s, %s, %s\n", + $r->{mod}, $r->{tag}, $r->{app} if ($debug); + foreach my $tag (sort keys %tag) { + foreach my $file (sort keys %{$tag{$tag}}) { + return 1 if (check_one($log, $r, $tag, $file)); + } + } + } + 0; +} + +sub check_one { + my ($log, $r, $tag, $file) = @_; + if ($file !~ m|$r->{mod}|) { + printf "$$: file not matched (%s, %s)\n", $file, $r->{mod} + if ($debug); + return 0; + } + printf "$$: file matched (%s, %s)\n", $file, $r->{mod} if ($debug); + if ($tag !~ m|$r->{tag}|) { + printf "$$: tag not matched (%s, %s)\n", + $tag, $r->{tag} if ($debug); + return 0; + } + printf "$$: tag matched (%s, %s)\n", $tag, $r->{tag} if ($debug); + if ($log =~ m|Approved by:[\t ]*$r->{app}|s) { + printf "$$: log matched (%s, %s)\n", $log, $r->{app} + if ($debug); + return 0; + } + printf "$$: log not matched (%s, %s)\n", $log, $r->{app} if ($debug); + printf "**** You need \"Approved by: %s\" line in your log entry.\n", + $r->{app}; + return 1; +} diff --git a/CVSROOT/approvers b/CVSROOT/approvers new file mode 100644 index 000000000000..919d84532d8a --- /dev/null +++ b/CVSROOT/approvers @@ -0,0 +1,22 @@ +# Configuration file for checking approvals. +# +# If you want to commit to specific module/branch defined in this file, +# you should get approval from appropriate party. +# +# This file is maintained by portmgr@FreeBSD.org. +# +# Format is tab separated. +# Use # as first character in a line for comment. +# +# You should satisfy all of lines which matching to modules and branches +# to commit. +# +# Please comment out the bottom line to activate commits only with approval. +# +# 1st column is regexp for module name. +# 2nd column is regexp for branch/tag name. +# 3rd column is regexp used with "Approved by:[\t ]*" line. +# +# $FreeBSD$ +# +#^ports/ .* (portmgr|portsmgr) diff --git a/CVSROOT/checkoutlist b/CVSROOT/checkoutlist index 17f85358afcb..c496820baeb0 100644 --- a/CVSROOT/checkoutlist +++ b/CVSROOT/checkoutlist @@ -33,6 +33,8 @@ # access access.master +approvecheck +approvers avail cfg.pm cfg_local.pm @@ -46,4 +48,5 @@ options rcstemplate tagcheck unwrap +verifymsgcheck wrap diff --git a/CVSROOT/verifymsgcheck b/CVSROOT/verifymsgcheck new file mode 100755 index 000000000000..b9829a77dfbf --- /dev/null +++ b/CVSROOT/verifymsgcheck @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w +# +# $FreeBSD$ + +use strict; +use lib $ENV{CVSROOT}; +use CVSROOT::cfg; +my $CVSROOT = $ENV{CVSROOT} || die "Can't determine CVSROOT (verifymsgcheck)!\n"; + +# Check "Approved by:" line. +system("$CVSROOT/CVSROOT/approvecheck", @ARGV); +if ($? >> 8) { + exit 1; +} + +# peter's edit post-processor.. +system("$CVSROOT/CVSROOT/logcheck", @ARGV); +if ($? >> 8) { + exit 1; +} |