From 6e62d9b7b537a672c1d807873289cbb9b6aec953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 12 Apr 2012 16:55:33 +0200 Subject: [PATCH] Allow use of a single Git clone for several branches. This reinstates commit 53329ecc618abf4fd5e4a6644d76413c43ad7b92, but uses "git pull --all", instead of "git fetch --all", so that local tracking branches get updated too. --- src/lib/Hydra/Helper/AddBuilds.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index d2187fe3..c6c7703a 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -323,7 +323,7 @@ sub fetchInputGit { my $storePath; mkpath(scmPath); - my $clonePath = scmPath . "/" . sha256_hex($uri.$branch); + my $clonePath = scmPath . "/" . sha256_hex($uri); my $stdout; my $stderr; if (! -d $clonePath) { @@ -335,7 +335,7 @@ sub fetchInputGit { # git pull + check rev chdir $clonePath or die $!; # !!! urgh, shouldn't do a chdir (my $res, $stdout, $stderr) = captureStdoutStderr(600, - ("git", "pull")); + ("git", "pull", "--all")); die "Error pulling latest change git repo at `$uri':\n$stderr" unless $res; (my $res1, $stdout, $stderr) = captureStdoutStderr(600, @@ -343,6 +343,10 @@ sub fetchInputGit { die "Cannot get head revision of Git branch '$branch' at `$uri':\n$stderr" unless $res1 ; + # Take the first commit ID returned by `ls-remote'. The + # assumption is that `ls-remote' returned both `refs/heads/BRANCH' + # and `refs/remotes/origin/BRANCH', and that both point at the + # same commit. my ($first) = split /\n/, $stdout; (my $revision, my $ref) = split ' ', $first; die unless $revision =~ /^[0-9a-fA-F]+$/;