summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-03-21 13:47:42 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-03-22 15:19:51 +0000
commitb7dec4080f555d202570cd3293465db52a9139ec (patch)
tree3eec0479d73c1f73f8b9ea7248fba160c9348c5a
parent8afbacc6da4ad5ccaf931d113df175bef22cc7b1 (diff)
Introduce git_for_each_ref
-rw-r--r--Debian/Dgit.pm15
-rwxr-xr-xinfra/dgit-repos-policy-debian11
2 files changed, 19 insertions, 7 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm
index 8b29ba2..4d9b81a 100644
--- a/Debian/Dgit.pm
+++ b/Debian/Dgit.pm
@@ -12,7 +12,7 @@ BEGIN {
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw(debiantag server_branch server_ref
- stat_exists
+ stat_exists git_for_each_ref
$package_re $branchprefix);
%EXPORT_TAGS = ( policyflags => qw() );
@EXPORT_OK = qw();
@@ -51,4 +51,17 @@ sub stat_exists ($) {
die "stat $f: $!";
}
+sub git_for_each_ref ($$) {
+ my ($pattern,$func) = @_;
+ # calls $func->($objid,$objtype,$fullrefname,$reftail);
+ # $reftail is RHS of ref after refs/\w+/
+ # breaks if $pattern matches any ref `refs/blah' where blah has no `/'
+ my $fh = new IO::File, "-|", qw(git for-each-ref), $pattern or die $!;
+ while (<$fh>) {
+ m#^(\w+)\s+(\w+)\s+(refs/\w+/(\S+))\s# or die "$_ ?";
+ $func->($1,$2,$3,$4);
+ }
+ $!=0; $?=0; close $fh or die "$pattern $? $!";
+}
+
1;
diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian
index 493fefd..66bf8be 100755
--- a/infra/dgit-repos-policy-debian
+++ b/infra/dgit-repos-policy-debian
@@ -221,14 +221,13 @@ sub action__check_package () {
return 0;
}
- open TAGL, "git for-each-ref '[r]efs/tags/*' |" or die $!;
- while (<TAGL>) {
- m#^(\w+) (\w+) (refs/tags/\S+)\s# or die "$_ ?";
- add_taint($1,$2,
- "tag $3 referred to this object in git tree but all".
+ git_for_each_ref('refs/tags', sub {
+ my ($objid,$objtype,$fullrefname,$tagname) = @_;
+ add_taint($objid,$objtype,
+ "tag $tagname referred to this object in git tree but all".
" previously pushed versions were found to have been".
" removed from NEW (ie, rejected) (or never arrived)");
- }
+ });
$?=0; $!=0; close TAGL or die "git for-each-ref $? $!";
return FRESHREPO;