From 895928422e17f65b279b6873887d519080c5b0b5 Mon Sep 17 00:00:00 2001 From: Daniel Holmes Date: Sun, 30 Jun 2013 18:55:25 +1000 Subject: [PATCH 1/3] Allow for bare repositories --- PHPCI/Model/Build/LocalBuild.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/PHPCI/Model/Build/LocalBuild.php b/PHPCI/Model/Build/LocalBuild.php index 38e2a914..e917d2c3 100644 --- a/PHPCI/Model/Build/LocalBuild.php +++ b/PHPCI/Model/Build/LocalBuild.php @@ -25,11 +25,22 @@ class LocalBuild extends Build * Create a working copy by cloning, copying, or similar. */ public function createWorkingCopy(Builder $builder, $buildPath) - { + { $reference = $this->getProject()->getReference(); $reference = substr($reference, -1) == '/' ? substr($reference, 0, -1) : $reference; $buildPath = substr($buildPath, 0, -1); $yamlParser = new YamlParser(); + + if(is_file($reference.'config')) { + //We're probably looing at a bare repository. We'll open the config and check + $gitConfig = parse_ini_file($reference.'config'); + if($gitConfig["core"]["bare"]) { + // Looks like we're right. We need to extract the archive! + $guid = uniqid(); + $builder->executeCommand('mkdir "/tmp/%s" && git archive master | tar -x -C "/tmp/%s"', $guid, $guid); + $reference = '/tmp/'.$guid; + } + } if (!is_file($reference . '/phpci.yml')) { $builder->logFailure('Project does not contain a phpci.yml file.'); From 62e8106130e4ff501437f1b0667d9a21d774998d Mon Sep 17 00:00:00 2001 From: Daniel Holmes Date: Sun, 30 Jun 2013 19:44:02 +1000 Subject: [PATCH 2/3] Tested And Resolved --- PHPCI/Model/Build/LocalBuild.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PHPCI/Model/Build/LocalBuild.php b/PHPCI/Model/Build/LocalBuild.php index e917d2c3..856a3f7c 100644 --- a/PHPCI/Model/Build/LocalBuild.php +++ b/PHPCI/Model/Build/LocalBuild.php @@ -31,9 +31,9 @@ class LocalBuild extends Build $buildPath = substr($buildPath, 0, -1); $yamlParser = new YamlParser(); - if(is_file($reference.'config')) { + if(is_file($reference.'/config')) { //We're probably looing at a bare repository. We'll open the config and check - $gitConfig = parse_ini_file($reference.'config'); + $gitConfig = parse_ini_file($reference.'/config',TRUE); if($gitConfig["core"]["bare"]) { // Looks like we're right. We need to extract the archive! $guid = uniqid(); From 9b458060fd9dbc8b97e8376581624c30a4173f6d Mon Sep 17 00:00:00 2001 From: Daniel Holmes Date: Mon, 1 Jul 2013 00:17:41 +1000 Subject: [PATCH 3/3] Final Version. Tested on ubuntu 12.04 64bit --- PHPCI/Model/Build/LocalBuild.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PHPCI/Model/Build/LocalBuild.php b/PHPCI/Model/Build/LocalBuild.php index 856a3f7c..07698d42 100644 --- a/PHPCI/Model/Build/LocalBuild.php +++ b/PHPCI/Model/Build/LocalBuild.php @@ -37,7 +37,7 @@ class LocalBuild extends Build if($gitConfig["core"]["bare"]) { // Looks like we're right. We need to extract the archive! $guid = uniqid(); - $builder->executeCommand('mkdir "/tmp/%s" && git archive master | tar -x -C "/tmp/%s"', $guid, $guid); + $builder->executeCommand('mkdir "/tmp/%s" && git --git-dir="%s" archive master | tar -x -C "/tmp/%s"', $guid, $reference, $guid); $reference = '/tmp/'.$guid; } }