Commit 496784e6 authored by Gary Wong's avatar Gary Wong
Browse files

Force nodes to check out the same tree-ish as seen by the portal.

In the case of branch refs, also switch to a local branch tracking the
origin repo, but retain the same HEAD the portal saw.
parent dd5acce7
......@@ -1138,7 +1138,6 @@ sub SetSites($$$$$$)
sub SetRepo($$$$$)
{
my ($prspecstr, $repourl, $reporef, $repohash, $perrmsg) = @_;
my $reponame = basename($repourl);
my $rspec = GeniXML::Parse($$prspecstr);
if (! defined($rspec)) {
......@@ -1158,17 +1157,14 @@ sub SetRepo($$$$$)
# Temporary, lets just throw an execute service onto each node.
# We put it before any existing execute services.
#
if ($reponame =~ /([^.]+)\.git$/) {
$reponame = $1;
}
my $command = "cd /local; sudo chmod 777 .;".
"git clone $repourl repository && cd repository; git checkout ";
if ($reporef =~ /heads/) {
my $branchname = basename($reporef);
$command .= "-B $branchname $repohash";
}
else {
$command .= "--detach $repohash";
my $command = "cd /local&&sudo chmod 777 .&&".
"git clone -n $repourl repository&&" .
"cd repository&&" .
"git checkout $repohash";
if ($reporef =~ m"^(refs/|)heads/(.+)") {
my $branchname = $2;
$command .= "&&git branch -ft $branchname origin/$branchname" .
"&&git checkout -B $branchname HEAD";
}
foreach my $node (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment