Git can handle commit references in git archive just fine so use them
parent
ba51027680
commit
bcbc50c0d6
|
@ -32,9 +32,7 @@ class GitArchiver implements ArchiverInterface
|
||||||
*/
|
*/
|
||||||
public function archive($sources, $target, $format, $sourceRef = null)
|
public function archive($sources, $target, $format, $sourceRef = null)
|
||||||
{
|
{
|
||||||
// Since git-archive no longer works with a commit ID in git 1.7.10,
|
if (null === $sourceRef) {
|
||||||
// use by default the HEAD reference instead of the commit sha1
|
|
||||||
if (null === $sourceRef || preg_match('/^[0-9a-f]{40}$/i', $sourceRef)) {
|
|
||||||
$sourceRef = 'HEAD';
|
$sourceRef = 'HEAD';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class GitArchiverTest extends ArchiverTest
|
||||||
|
|
||||||
// Test archive
|
// Test archive
|
||||||
$archiver = new GitArchiver();
|
$archiver = new GitArchiver();
|
||||||
$archiver->archive($package->getSourceUrl(), $target, 'zip', 'master');
|
$archiver->archive($package->getSourceUrl(), $target, 'zip', 'master^1');
|
||||||
$this->assertFileExists($target);
|
$this->assertFileExists($target);
|
||||||
|
|
||||||
unlink($target);
|
unlink($target);
|
||||||
|
@ -46,7 +46,7 @@ class GitArchiverTest extends ArchiverTest
|
||||||
|
|
||||||
// Test archive
|
// Test archive
|
||||||
$archiver = new GitArchiver();
|
$archiver = new GitArchiver();
|
||||||
$archiver->archive($package->getSourceUrl(), $target, 'tar', 'master');
|
$archiver->archive($package->getSourceUrl(), $target, 'tar', 'master^1');
|
||||||
$this->assertFileExists($target);
|
$this->assertFileExists($target);
|
||||||
|
|
||||||
unlink($target);
|
unlink($target);
|
||||||
|
@ -78,6 +78,18 @@ class GitArchiverTest extends ArchiverTest
|
||||||
throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput());
|
throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result = file_put_contents('d', 'c');
|
||||||
|
if (false === $result) {
|
||||||
|
chdir($currentWorkDir);
|
||||||
|
throw new \RuntimeException('Could not save file.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->process->execute('git add d && git commit -m "commit d" -q');
|
||||||
|
if ($result > 0) {
|
||||||
|
chdir($currentWorkDir);
|
||||||
|
throw new \RuntimeException('Could not commit: '.$this->process->getErrorOutput());
|
||||||
|
}
|
||||||
|
|
||||||
chdir($currentWorkDir);
|
chdir($currentWorkDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue