chiark / gitweb /
Provide for checking git presence via http[s].
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 18 Jul 2015 14:59:06 +0000 (15:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jul 2015 18:36:15 +0000 (19:36 +0100)
debian/changelog
dgit

index c6b28b577d9a50c981ab749ad6eb74a3f258650e..6081671f29e727e2b9b98b6ebbeeb6489ff8272b 100644 (file)
@@ -14,6 +14,7 @@ dgit (0.31~~) unstable; urgency=low
   Access machinery:
   * Provide for different access mechanisms when pushing.
   * Provide for configurable git url suffix.
   Access machinery:
   * Provide for different access mechanisms when pushing.
   * Provide for configurable git url suffix.
+  * Provide for checking git presence via http[s].
   * Do some quoting on debug output (needed if the server might not
     be trustworthy and might send us bad stuff).
 
   * Do some quoting on debug output (needed if the server might not
     be trustworthy and might send us bad stuff).
 
diff --git a/dgit b/dgit
index 8f4a71c2a3683087b020520dcc05fea6eb8a1fe5..70ff8c4b7a6a351bf866feb111956388b6ad8721 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1058,6 +1058,24 @@ sub check_for_git () {
        }
        failedcmd @cmd unless $r =~ m/^[01]$/;
        return $r+0;
        }
        failedcmd @cmd unless $r =~ m/^[01]$/;
        return $r+0;
+    } elsif ($how eq 'url') {
+       my $prefix = access_cfg('git-check-url','git-url');
+       my $suffix = access_cfg('git-check-suffix','git-suffix',
+                               'RETURN-UNDEF') // '.git';
+       my $url = "$prefix/$package$suffix";
+       my @cmd = (qw(curl -sS -I), $url);
+       my $result = cmdoutput @cmd;
+       $result =~ m/^\S+ (404|200) /s or
+           fail "unexpected results from git check query - ".
+               Dumper($prefix, $result);
+       my $code = $1;
+       if ($code eq '404') {
+           return 0;
+       } elsif ($code eq '200') {
+           return 1;
+       } else {
+           die;
+       }
     } elsif ($how eq 'true') {
        return 1;
     } elsif ($how eq 'false') {
     } elsif ($how eq 'true') {
        return 1;
     } elsif ($how eq 'false') {