Initial implementation CI environments

This commit is contained in:
Stepan Strelets 2017-03-23 15:53:24 +03:00 committed by Dmitry Khomutov
commit 047cedaab3
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
21 changed files with 850 additions and 42 deletions

View file

@ -4,6 +4,7 @@ namespace PHPCensor\Model\Build;
use PHPCensor\Model\Build;
use PHPCensor\Builder;
use Psr\Log\LogLevel;
/**
* Remote Git Build Model
@ -33,6 +34,10 @@ class RemoteGitBuild extends Build
$success = $this->cloneByHttp($builder, $buildPath);
}
if ($success) {
$success = $this->mergeBranches($builder, $buildPath);
}
if (!$success) {
$builder->logFailure('Failed to clone remote git repository.');
return false;
@ -41,6 +46,28 @@ class RemoteGitBuild extends Build
return $this->handleConfig($builder, $buildPath);
}
/**
* @param Builder $builder
* @param string $buildPath
* @return bool
*/
protected function mergeBranches(Builder $builder, $buildPath)
{
$branches = $this->getExtra('branches');
if (!empty($branches)) {
$cmd = 'cd "%s" && git merge --quiet origin/%s';
foreach ($branches as $branch) {
$success = $builder->executeCommand($cmd, $buildPath, $branch);
if (!$success) {
$builder->log('Fail merge branch origin/'.$branch, LogLevel::ERROR);
return false;
}
$builder->log('Merged branch origin/'.$branch, LogLevel::INFO);
}
}
return true;
}
/**
* Use an HTTP-based git clone.
*/