summaryrefslogtreecommitdiffstats
path: root/CVSROOT/approvecheck
diff options
context:
space:
mode:
authorkrion <krion@FreeBSD.org>2004-05-26 08:57:06 +0000
committerkrion <krion@FreeBSD.org>2004-05-26 08:57:06 +0000
commit645f7f9a7c9fdbf0084690574767ef8367f57dd9 (patch)
treeb890b4372372ea7a2f47f17907571a066eefd6b4 /CVSROOT/approvecheck
parent7a9cfdcb93edc826d48d1ac97e8b6cb96b98111c (diff)
downloadFreeBSD-ports-645f7f9a7c9fdbf0084690574767ef8367f57dd9.zip
FreeBSD-ports-645f7f9a7c9fdbf0084690574767ef8367f57dd9.tar.gz
- 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/approvecheck')
-rwxr-xr-xCVSROOT/approvecheck115
1 files changed, 115 insertions, 0 deletions
diff --git a/CVSROOT/approvecheck b/CVSROOT/approvecheck
new file mode 100755
index 0000000..8d063f6
--- /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;
+}
OpenPOWER on IntegriCloud