@ISA = qw(Exporter);
@EXPORT = qw(debiantag
$package_re);
- %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+ %EXPORT_TAGS = ( policyflags => qw() );
@EXPORT_OK = qw();
}
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/~:/_%/;
# 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
#
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";
use Fcntl qw(:flock);
use File::Path qw(rmtree);
-use Debian::Dgit;
+use Debian::Dgit qw(:DEFAULT :policyflags);
open DEBUG, ">/dev/null" or die $!;
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));
# 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";
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;