10 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
14 @EXPORT = qw(debiantag server_branch server_ref
15 stat_exists git_for_each_ref
16 $package_re $branchprefix);
17 %EXPORT_TAGS = ( policyflags => qw() );
23 our $package_re = '[0-9a-z][-+.0-9a-z]*';
24 our $branchprefix = 'dgit';
26 # policy hook exit status bits
27 # see dgit-repos-server head comment for documentation
28 # 1 is reserved in case something fails with `exit 1'
29 sub NOFFCHECK () { return 2; }
30 sub FRESHREPO () { return 4; }
39 sub server_branch ($) { return "$branchprefix/$_[0]"; }
40 sub server_ref ($) { return "refs/".server_branch($_[0]); }
45 return 0 if $!==&ENOENT;
49 sub git_for_each_ref ($$) {
50 my ($pattern,$func) = @_;
51 # calls $func->($objid,$objtype,$fullrefname,$reftail);
52 # $reftail is RHS of ref after refs/\w+/
53 # breaks if $pattern matches any ref `refs/blah' where blah has no `/'
54 my $fh = new IO::File, "-|", qw(git for-each-ref), $pattern or die $!;
56 m#^(\w+)\s+(\w+)\s+(refs/\w+/(\S+))\s# or die "$_ ?";
59 $!=0; $?=0; close $fh or die "$pattern $? $!";
62 sub git_for_each_tag_referring ($$) {
63 my ($objreferring, $func) = @_;
64 # calls $func->($objid,$fullrefname,$tagname);
65 git_for_each_ref('refs/tags', sub {
66 my ($objid,$objtype,$fullrefname,$tagname) = @_;
67 next unless $objtype eq 'tag';
68 next if defined $objreferring and $objid ne $objreferring;
69 $func->($objid,$fullrefname,$tagname);