|
@@ -25,7 +25,8 @@ class GetSource extends Command
|
|
|
->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
|
|
|
->addOption('remote-name', null, InputOption::VALUE_REQUIRED, 'Rename the remote to this name.', "upstream")
|
|
|
->addOption('push', null, InputOption::VALUE_NONE, 'Push to the remote.')
|
|
|
- ->addOption('timeout', null, InputOption::VALUE_OPTIONAL, 'Git process timeout in seconds', 60)
|
|
|
+ ->addOption('timeout', null, InputOption::VALUE_OPTIONAL, 'Git process timeout in seconds', 10)
|
|
|
+ ->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'get a diferente branch from the specified on the ini-file', "")
|
|
|
;
|
|
|
}
|
|
|
|
|
@@ -46,15 +47,15 @@ class GetSource extends Command
|
|
|
$git_path = $dirname.'/'.$sec;
|
|
|
$url = $conf["url"];
|
|
|
// Verifico si tiene ssh como protocolo y si la url es de gogs
|
|
|
- $protocol = 'ssh://';
|
|
|
- if (substr($url, 0, strlen($protocol)) !== $protocol && strpos($url, 'gogs.infra.flowdat.com') !== false) {
|
|
|
+ $url_info = parse_url($url);
|
|
|
+ if(isset($url_info["host"]) and (!isset($url_info["scheme"]) or empty($url_info["scheme"]))){
|
|
|
+ $protocol = 'ssh://';
|
|
|
$url = $protocol . $url;
|
|
|
}
|
|
|
try {
|
|
|
$output->writeln($url . " -> " . $git_path);
|
|
|
$git->clone($url, $git_path);
|
|
|
- } catch (GitException $e) {
|
|
|
- throw $e;
|
|
|
+ } catch (GitException $e){
|
|
|
$output->write("repo $sec exists \n");
|
|
|
}
|
|
|
$git->setRepository($git_path);
|
|
@@ -64,9 +65,18 @@ class GetSource extends Command
|
|
|
} catch (GitException $e) {
|
|
|
}
|
|
|
$git->remote->add($input->getOption("remote-name"), $url);
|
|
|
- $git->fetch($input->getOption("remote-name"));
|
|
|
-
|
|
|
- $git->checkout($conf["branch"]);
|
|
|
+ try {
|
|
|
+ $git->fetch($input->getOption("remote-name"));
|
|
|
+ } catch( GitException $e) {
|
|
|
+ $output->writeln("<error>".$e->getMessage()."</error>");
|
|
|
+ }
|
|
|
+ $branch_from_options = $input->getOption("branch");
|
|
|
+ if(!empty($branch_from_options)){
|
|
|
+ $git->checkout($branch_from_options);
|
|
|
+ $conf["branch"] = $branch_from_options;
|
|
|
+ }else{
|
|
|
+ $git->checkout($conf["branch"]);
|
|
|
+ }
|
|
|
$branches = $git->branch(array("all" => false,"remotes" => true));
|
|
|
|
|
|
if(isset($branches["remotes/" . $input->getOption("remote-name") . "/" . $conf["branch"]])){
|