Improved logging in \ncc\Classes > GitClient
This commit is contained in:
parent
0281ba2af4
commit
a995732ff7
1 changed files with 12 additions and 2 deletions
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
public static function cloneRepository(string $url): string
|
public static function cloneRepository(string $url): string
|
||||||
{
|
{
|
||||||
|
Console::outVerbose('Cloning repository: ' . $url);
|
||||||
$path = Functions::getTmpDir();
|
$path = Functions::getTmpDir();
|
||||||
$process = new Process(["git", "clone", $url, $path]);
|
$process = new Process(["git", "clone", $url, $path]);
|
||||||
$process->setTimeout(3600); // 1 hour
|
$process->setTimeout(3600); // 1 hour
|
||||||
|
@ -33,7 +34,8 @@
|
||||||
if (!$process->isSuccessful())
|
if (!$process->isSuccessful())
|
||||||
throw new GitCloneException($process->getErrorOutput());
|
throw new GitCloneException($process->getErrorOutput());
|
||||||
|
|
||||||
Console::outVerbose('Repository cloned to ' . $path);
|
Console::outVerbose('Repository cloned to: ' . $path);
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
*/
|
*/
|
||||||
public static function checkout(string $path, string $branch)
|
public static function checkout(string $path, string $branch)
|
||||||
{
|
{
|
||||||
|
Console::outVerbose('Checking out branch' . $branch);
|
||||||
$process = new Process(["git", "checkout", $branch], $path);
|
$process = new Process(["git", "checkout", $branch], $path);
|
||||||
$process->setTimeout(3600); // 1 hour
|
$process->setTimeout(3600); // 1 hour
|
||||||
$process->run(function ($type, $buffer)
|
$process->run(function ($type, $buffer)
|
||||||
|
@ -63,7 +66,7 @@
|
||||||
if (!$process->isSuccessful())
|
if (!$process->isSuccessful())
|
||||||
throw new GitCheckoutException($process->getErrorOutput());
|
throw new GitCheckoutException($process->getErrorOutput());
|
||||||
|
|
||||||
Console::outVerbose('Checked out branch ' . $branch);
|
Console::outVerbose('Checked out branch: ' . $branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,6 +78,7 @@
|
||||||
*/
|
*/
|
||||||
public static function getTags(string $path): array
|
public static function getTags(string $path): array
|
||||||
{
|
{
|
||||||
|
Console::outVerbose('Getting tags for repository: ' . $path);
|
||||||
$process = new Process(["git", "fetch", '--all', '--tags'] , $path);
|
$process = new Process(["git", "fetch", '--all', '--tags'] , $path);
|
||||||
$process->setTimeout(3600); // 1 hour
|
$process->setTimeout(3600); // 1 hour
|
||||||
$process->run(function ($type, $buffer)
|
$process->run(function ($type, $buffer)
|
||||||
|
@ -96,6 +100,12 @@
|
||||||
throw new GitTagsException($process->getErrorOutput());
|
throw new GitTagsException($process->getErrorOutput());
|
||||||
|
|
||||||
$tags = explode(PHP_EOL, $process->getOutput());
|
$tags = explode(PHP_EOL, $process->getOutput());
|
||||||
|
$tags = array_filter($tags, function ($tag)
|
||||||
|
{
|
||||||
|
return !empty($tag);
|
||||||
|
});
|
||||||
|
|
||||||
|
Console::outDebug('found ' . count($tags) . ' tags');
|
||||||
return array_filter($tags);
|
return array_filter($tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue