Implement clone_depth setting in build_settings, to allow shallow clones. Fixes #391

This commit is contained in:
Dan Cryer 2014-05-05 21:03:44 +01:00
parent c164295170
commit ca6890a5c3

View file

@ -54,7 +54,15 @@ class RemoteGitBuild extends Build
*/
protected function cloneByHttp(Builder $builder, $cloneTo)
{
$cmd = 'git clone -b %s %s "%s"';
$cmd = 'git clone ';
$depth = $builder->getConfig('clone_depth');
if (!is_null($depth)) {
$cmd .= ' --depth ' . intval($depth) . ' ';
}
$cmd .= ' -b %s %s "%s"';
$success = $builder->executeCommand($cmd, $this->getBranch(), $this->getCloneUrl(), $cloneTo);
if (!empty($commit) && $commit != 'Manual') {
@ -80,14 +88,20 @@ class RemoteGitBuild extends Build
}
// Do the git clone:
$cmd = 'git clone -b %s %s "%s"';
$cmd = 'git clone ';
$depth = $builder->getConfig('clone_depth');
if (!is_null($depth)) {
$cmd .= ' --depth ' . intval($depth) . ' ';
}
$cmd .= ' -b %s %s "%s"';
if (!IS_WIN) {
$cmd = 'export GIT_SSH="'.$gitSshWrapper.'" && ' . $cmd;
}
var_dump($cmd);
$success = $builder->executeCommand($cmd, $this->getBranch(), $this->getCloneUrl(), $cloneTo);
// Checkout a specific commit if we need to: