From 5ebc2e5419d11f195312d320b0b1eab00072cab1 Mon Sep 17 00:00:00 2001 From: Tino Breddin Date: Thu, 31 Jul 2014 21:42:13 +0200 Subject: [PATCH] only checkout the target branch when topgit is used --- src/lib/Hydra/Plugin/GitInput.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/Hydra/Plugin/GitInput.pm b/src/lib/Hydra/Plugin/GitInput.pm index 86674335..b551db9b 100644 --- a/src/lib/Hydra/Plugin/GitInput.pm +++ b/src/lib/Hydra/Plugin/GitInput.pm @@ -39,14 +39,14 @@ sub _cloneRepo { # to determine if this is a top-git branch. if (defined $deepClone) { - # Checkout the branch to look at its content. - $res = run(cmd => ["git", "checkout", "--force", "$branch"], dir => $clonePath); - die "error checking out Git branch '$branch' at `$uri':\n$res->{stderr}" if $res->{status}; - # Clean to remove potentially present artifacts after forcing branch switch - $res = run(cmd => ["git", "clean", "-d", "-x", "--force", "--force"], dir => $clonePath); - print STDERR "warning: `git clean -d -x --force --force' failed::\n$res->{stderr}" if $res->{status}; + # Is the target branch a topgit branch? + $res = run(cmd => ["git", "ls-tree", "-r", "$branch", ".topgit"], dir => $clonePath); + + if ($res->{stdout} != "") { + # Checkout the branch to look at its content. + $res = run(cmd => ["git", "checkout", "--force", "$branch"], dir => $clonePath); + die "error checking out Git branch '$branch' at `$uri':\n$res->{stderr}" if $res->{status}; - if (-f ".topdeps") { # This is a TopGit branch. Fetch all the topic branches so # that builders can run "tg patch" and similar. $res = run(cmd => ["tg", "remote", "--populate", "origin"], dir => $clonePath, timeout => 600);