When starting a manual build, replace the "Manual" commit id with the HEAD hash.
Close #928
This commit is contained in:
parent
634b246ed5
commit
209454c5f6
|
@ -124,16 +124,16 @@ class RemoteGitBuild extends Build
|
|||
$success = true;
|
||||
$commit = $this->getCommitId();
|
||||
|
||||
$chdir = IS_WIN ? 'cd /d "%s"' : 'cd "%s"';
|
||||
|
||||
if (!empty($commit) && $commit != 'Manual') {
|
||||
$cmd = 'cd "%s"';
|
||||
$cmd = $chdir . ' && git checkout %s --quiet';
|
||||
$success = $builder->executeCommand($cmd, $cloneTo, $commit);
|
||||
}
|
||||
|
||||
if (IS_WIN) {
|
||||
$cmd = 'cd /d "%s"';
|
||||
}
|
||||
|
||||
$cmd .= ' && git checkout %s --quiet';
|
||||
|
||||
$success = $builder->executeCommand($cmd, $cloneTo, $this->getCommitId());
|
||||
// Always update the commit hash with the actual HEAD hash
|
||||
if ($builder->executeCommand($chdir . ' && git rev-parse HEAD', $cloneTo)) {
|
||||
$this->setCommitId(trim($builder->getLastOutput()));
|
||||
}
|
||||
|
||||
return $success;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace PHPCI\Service;
|
||||
|
||||
use PHPCI\Helper\Lang;
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Model\Project;
|
||||
use PHPCI\Store\BuildStore;
|
||||
|
@ -59,6 +60,7 @@ class BuildService
|
|||
$build->setCommitId($commitId);
|
||||
} else {
|
||||
$build->setCommitId('Manual');
|
||||
$build->setCommitMessage(Lang::get('manual_build'));
|
||||
}
|
||||
|
||||
if (!is_null($branch)) {
|
||||
|
|
|
@ -57,7 +57,7 @@ class BuildServiceTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertNull($returnValue->getStarted());
|
||||
$this->assertNull($returnValue->getFinished());
|
||||
$this->assertNull($returnValue->getLog());
|
||||
$this->assertEmpty($returnValue->getCommitMessage());
|
||||
$this->assertEquals(\PHPCI\Helper\Lang::get('manual_build'), $returnValue->getCommitMessage());
|
||||
$this->assertNull($returnValue->getCommitterEmail());
|
||||
$this->assertNull($returnValue->getExtra());
|
||||
$this->assertEquals('master', $returnValue->getBranch());
|
||||
|
|
Loading…
Reference in a new issue