|
@@ -23,7 +23,8 @@ class GetSource extends Command
|
|
|
->setHelp('This command allows you to fetch code based on the git.ini file configuration...')
|
|
|
|
|
|
->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
|
|
|
- ->addOption('source-name', null, InputOption::VALUE_REQUIRED, 'Rename the source to this name.', "upstream")
|
|
|
+ ->addOption('remote-name', null, InputOption::VALUE_REQUIRED, 'Rename the remote to this name.', "upstream")
|
|
|
+ ->addOption('push', null, InputOption::VALUE_NONE, 'Push to the remote.')
|
|
|
;
|
|
|
}
|
|
|
|
|
@@ -52,13 +53,34 @@ class GetSource extends Command
|
|
|
$git->setRepository($git_path);
|
|
|
|
|
|
try{
|
|
|
- $git->remote->rm($input->getOption("source-name"));
|
|
|
+ $git->remote->rm($input->getOption("remote-name"));
|
|
|
}catch (GitException $e){
|
|
|
|
|
|
}
|
|
|
- $git->remote->add($input->getOption("source-name"), $conf["url"]);
|
|
|
+ $git->remote->add($input->getOption("remote-name"), $conf["url"]);
|
|
|
+ $git->fetch($input->getOption("remote-name"));
|
|
|
+
|
|
|
|
|
|
$git->checkout($conf["branch"]);
|
|
|
+ $branches = $git->branch(array("all" => false,"remotes" => true));
|
|
|
+
|
|
|
+ if(isset($branches["remotes/" . $input->getOption("remote-name") . "/" . $conf["branch"]])){
|
|
|
+ $git->merge($input->getOption("remote-name")."/".$conf["branch"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $status = $git->status();
|
|
|
+
|
|
|
+ if(isset($status["changes"]) and !empty($status["changes"])){
|
|
|
+ foreach($status["changes"] as $change){
|
|
|
+ $output->writeln("\t" . $change["file"] . " is not commited");
|
|
|
+ }
|
|
|
+ }else if($input->getOption("push")){
|
|
|
+ $git->push($input->getOption("remote-name"), $conf["branch"]);
|
|
|
+
|
|
|
+ foreach($git->tag() as $tag){
|
|
|
+ $git->push($input->getOption("remote-name"), $tag, array('force' => true));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|