function Git::runCommands
Runs a set of commands using the $url or a variation of it (with auth, ssh, ..)
Commands should use %url% placeholders for the URL instead of inlining it to allow this function to do its job %sanitizedUrl% is also automatically replaced by the url without user/pass
As soon as a single command fails it will halt, so assume the commands are run as && in bash
Parameters
non-empty-array<non-empty-list<string>> $commands:
mixed $commandOutput the output will be written into this var if passed by ref: if a callable is passed it will be used as output handler
2 calls to Git::runCommands()
- Git::getMirrorDefaultBranch in vendor/
composer/ composer/ src/ Composer/ Util/ Git.php - Git::syncMirror in vendor/
composer/ composer/ src/ Composer/ Util/ Git.php
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Git.php, line 77
Class
- Git
- @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\UtilCode
public function runCommands(array $commands, string $url, ?string $cwd, bool $initialClone = false, &$commandOutput = null) : void {
$callables = [];
foreach ($commands as $cmd) {
$callables[] = static function (string $url) use ($cmd) : array {
$map = [
'%url%' => $url,
'%sanitizedUrl%' => Preg::replace('{://([^@]+?):(.+?)@}', '://', $url),
];
return array_map(static function ($value) use ($map) : string {
return $map[$value] ?? $value;
}, $cmd);
};
}
// @phpstan-ignore method.deprecated
$this->runCommand($callables, $url, $cwd, $initialClone, $commandOutput);
}