chiark / gitweb /
Export policy hook exist status flags from Dgit.pm
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 21 Mar 2015 10:53:10 +0000 (10:53 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 22 Mar 2015 15:19:27 +0000 (15:19 +0000)
Debian/Dgit.pm
infra/dgit-repos-policy-debian
infra/dgit-repos-server

index 3fe0309304feb8b8d8dd8d47b311b4c4fd0318ec..a124930b39a6adf47953f5a0c604af3e9254bf52 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
     @ISA         = qw(Exporter);
     @EXPORT      = qw(debiantag
                       $package_re);
-    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+    %EXPORT_TAGS = ( policyflags => qw() );
     @EXPORT_OK   = qw();
 }
 
@@ -21,6 +21,18 @@ our @EXPORT_OK;
 
 our $package_re = '[0-9a-z][-+.0-9a-z]*';
 
+
+# policy hook exit status bits
+# any unexpected bits mean failure, and then known set bits are ignored
+
+sub NOFFCHECK () { return 2; }
+# suppress dgit-repos-server's ff check ("push" only)
+
+sub FRESHREPO () { return 4; }
+# blow away repo right away (ie, as if before push or fetch)
+# ("check-package" only)
+
+
 sub debiantag ($) { 
     my ($v) = @_;
     $v =~ y/~:/_%/;
index db15310314234c90bc67f39f44b4504f258f2d15..46f103952a65d9bf6f08f539b547143ebc62a18d 100755 (executable)
@@ -9,12 +9,6 @@
 #   dgit-repos-policy-debian ... push PACKAGE \
 #         VERSION SUITE TAGNAME DELIBERATELIES [...]
 #
-# exit status is bitmap; bit weights (values) as follows
-#   1    failure; operation must be rejected; other bits will be ignored
-#   2    suppress dgit-repos-server's ff check ("push" only)
-#   4    blow away repo away right away (ie before push or fetch)
-#           ("check-package" only)
-#
 # cwd for push is a temporary repo where the to-be-pushed objects have
 #  been received; TAGNAME is the version-based tag
 #
@@ -25,7 +19,7 @@ use strict;
 use POSIX;
 use JSON;
 
-use Debian::Dgit;
+use Debian::Dgit qw(:DEFAULT :policyflags);
 
 our $distro = shift @ARGV // die "need DISTRO";
 our $repos = shift @ARGV // die "need DGIT-REPOS-DIR";
index 6d7fb6316ca4e3f4fe464e679a77ff03970aa389..3f41a0bb9ba356093a6f2ce2259875b8b4fcb287 100755 (executable)
@@ -87,7 +87,7 @@ use POSIX;
 use Fcntl qw(:flock);
 use File::Path qw(rmtree);
 
-use Debian::Dgit;
+use Debian::Dgit qw(:DEFAULT :policyflags);
 
 open DEBUG, ">/dev/null" or die $!;
 
@@ -504,7 +504,7 @@ sub checks () {
     debug "translated version $v";
     $tagname eq "debian/$v" or die;
 
-    my ($policy) = policyhook(2,'push',$package,
+    my ($policy) = policyhook(NOFFCHECK, 'push',$package,
                              $version,$suite,$tagname,
                              join(",",@delberatelies));
 
@@ -512,7 +512,7 @@ sub checks () {
 
     # check that our ref is being fast-forwarded
     debug "oldcommit $oldcommit";
-    if (!($policy & 2) && $oldcommit =~ m/[^0]/) {
+    if (!($policy & NOFFCHECK) && $oldcommit =~ m/[^0]/) {
        $?=0; $!=0; my $mb = `git merge-base $commit $oldcommit`;
        chomp $mb;
        $mb eq $oldcommit or reject "not fast forward on dgit branch";
@@ -631,8 +631,8 @@ sub parseargsdispatch () {
 
     reject "unknown method" unless $mainfunc;
 
-    my ($policy, $pollock) = policyhook(4, 'check-package',$package);
-    if ($policy & 4) {
+    my ($policy, $pollock) = policyhook(FRESHREPO,'check-package',$package);
+    if ($policy & FRESHREPO) {
        my $garbagerepo = "$dgitrepos/_tmp/${package}_garbage";
        acquiretree($garbagerepo,1);
        rmtree $garbagerepo;