Package: devscripts
Version: 2.11.2
Severity: wishlist
Tags: patch

Attached introduces support for -b in Vcs-Git fields to debcheckout.

For example:

Vcs-Git: git://anonscm.debian.org/mirrorer/reprepro.git -b squeeze

This way a debcheckout can be targeted at a specific branch while the
Vcs-Git field can still be manually used as arguments to git clone
to manually get the right command.

Thanks in advance,
        Bernhard R. Link
>From ed8d94240d5978dc1619965d5957b26f58f68578 Mon Sep 17 00:00:00 2001
From: "Bernhard R. Link" <[email protected]>
Date: Sun, 8 Jan 2012 13:52:27 +0100
Subject: [PATCH] debcheckout: allow specifying branch in git repro
 identifiers

Add support for Vcs-Git to specify a branch to checkout using -b.
(git-clone -b was introduced in git v1.6.5-rc0,
so should available since squeeze).

Signed-off-by: Bernhard R. Link <[email protected]>
---
 scripts/debcheckout.pl |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/debcheckout.pl b/scripts/debcheckout.pl
index 3e23505..2e99061 100755
--- a/scripts/debcheckout.pl
+++ b/scripts/debcheckout.pl
@@ -511,7 +511,13 @@ sub checkout_repo($$$) {
 	    @cmd = ("cvs", "-d", $root, "checkout", $module);
 	}
 	when ("darcs") { @cmd = ("darcs", "get", $repo_url); }
-	when ("git") { @cmd = ("git", "clone", $repo_url); }
+	when ("git") {
+	    if ($repo_url =~ m|(.*)\s+-b\s+(.*)|) {
+	      @cmd = ("git", "clone", $1, "-b", $2);
+	    } else {
+	      @cmd = ("git", "clone", $repo_url);
+	    }
+	}
 	when ("hg") { @cmd = ("hg", "clone", $repo_url); }
 	when ("svn") { @cmd = ("svn", "co", $repo_url); }
 	default { die "unsupported version control system '$repo_type'.\n"; }
@@ -877,6 +883,7 @@ sub print_repo($$) {
 sub git_ls_remote($$) {
     my ($url, $prefix) = @_;
 
+    $url =~ s|\s+-b\s+.*||;
     my $cmd = "git ls-remote '$url'";
     $cmd .= " '$prefix/*'" if length $prefix;
     open GIT, "$cmd |" or die "can't execute $cmd\n";
@@ -995,7 +1002,7 @@ sub main() {
 	    $pkg = $1;
 	} elsif ($repo_url =~ m!([a-z0-9.+-]+)/trunk/?!) { # svn with $pkg/{trunk,tags,branches}
 	    $pkg = $1;
-	} elsif ($repo_url =~ /([a-z0-9.+-]+)\.git$/) { # git
+	} elsif ($repo_url =~ /([a-z0-9.+-]+)\.git(\s+-b\s+.*)?$/) { # git
 	    $pkg = $1;
 	} elsif ($repo_url =~ /([a-z0-9.+-]+)$/) { # catch-all
 	    $pkg = $1;
-- 
1.7.8.2

Reply via email to