|
@@ -2,17 +2,14 @@
|
|
|
|
|
|
namespace FD3\Command;
|
|
|
|
|
|
+use PHPGit\Exception\GitException;
|
|
|
+use PHPGit\Git;
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
-use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
-use PHPGit\Git;
|
|
|
-use PHPGit\Exception\GitException;
|
|
|
-
|
|
|
-use WriteiniFile\WriteiniFile;
|
|
|
-
|
|
|
class TagModulesCommand extends Command
|
|
|
{
|
|
|
protected function configure()
|
|
@@ -32,7 +29,7 @@ class TagModulesCommand extends Command
|
|
|
{
|
|
|
$file = $input->getArgument("ini_file");
|
|
|
$tag = $input->getArgument("tag");
|
|
|
- $optionRemoteGit = $input->getOption('remote_git');
|
|
|
+ $optionRemoteGit = $input->getOption('remote_git');
|
|
|
if (strtolower(substr($tag, 0, 1)) == 'v') {
|
|
|
$version = explode(".", $tag);
|
|
|
if (count($version) == 3) {
|
|
@@ -54,19 +51,19 @@ class TagModulesCommand extends Command
|
|
|
try {
|
|
|
$git = new Git();
|
|
|
$git_path = $dirname . '/' . $sec;
|
|
|
- $cd_path = "cd " . $git_path;
|
|
|
+ $cd_path = "cd " . $git_path;
|
|
|
// agrego datos del usuario
|
|
|
$git->config->add('user.email', 'drone@flowdat.com', ["global" => true]);
|
|
|
$git->config->add('user.name', 'drone', ["global" => true]);
|
|
|
// agrego el path del repositorio
|
|
|
- $git->setRepository($git_path);
|
|
|
+ $git->setRepository($git_path);
|
|
|
// necesito traer todos los branch's para ver si ya existe
|
|
|
$branchs = $git->branch(['all' => true]);
|
|
|
$findBranch = false;
|
|
|
$branchRemote = null;
|
|
|
$branchOrigen = null;
|
|
|
// verifico si el branch a crear ya existe
|
|
|
- foreach ($branchs as $branch) {
|
|
|
+ foreach ($branchs as $branch) {
|
|
|
if ($branch['current']) {
|
|
|
$branchOrigen = $branch['name'];
|
|
|
}
|
|
@@ -80,24 +77,43 @@ class TagModulesCommand extends Command
|
|
|
$output->writeln('Creando la rama ' . $version);
|
|
|
$git->branch->create($version);
|
|
|
}
|
|
|
- $git->add('composer.json');
|
|
|
- $git->add('composer.lock');
|
|
|
|
|
|
- $output->writeln('Commit de los composer');
|
|
|
+ $flag = false;
|
|
|
+ $files = [
|
|
|
+ 'composer.json',
|
|
|
+ 'composer.lock',
|
|
|
+ ];
|
|
|
+ $status = $git->status();
|
|
|
+ if (isset($status['changes'])) {
|
|
|
+ foreach ($status['changes'] as $file) {
|
|
|
+ if (in_array($file['file'], $files)) {
|
|
|
+ $git->add($file);
|
|
|
+ $flag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($flag == false) {
|
|
|
+ $output->writeln('No hay cambios en el repositorio');
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $output->writeln('Commit de los composer');
|
|
|
$command = $cd_path . "; git commit -am 'Composer para la version " . $version . " y el tag " . $tag . "'";
|
|
|
$output->writeln("\t" . $command);
|
|
|
shell_exec($command);
|
|
|
-
|
|
|
- // cambio a la rama de la version y agrego los archivos modificados
|
|
|
+
|
|
|
+ // cambio a la rama de la version y agrego los archivos modificados
|
|
|
$output->writeln('Checkout de la rama ' . $version);
|
|
|
$git->checkout($version);
|
|
|
|
|
|
$output->writeln('Merge entre la rama ' . $version . ' y ' . $branchOrigen);
|
|
|
$git->merge($branchOrigen, 'Merge entre la rama ' . $version . ' y ' . $branchOrigen, ['strategy' => 'ours']);
|
|
|
-
|
|
|
+
|
|
|
$output->writeln('Push de la rama ' . $version);
|
|
|
- $command = $cd_path . "; git push " . $optionRemoteGit . " " . $version;
|
|
|
- $output->writeln("\t" . $command);
|
|
|
+ $command = $cd_path . "; git push " . $optionRemoteGit . " " . $version;
|
|
|
+ $output->writeln("\t" . $command);
|
|
|
shell_exec($command);
|
|
|
// estoy creando un tag
|
|
|
$tags = $git->tag();
|
|
@@ -114,19 +130,21 @@ class TagModulesCommand extends Command
|
|
|
}
|
|
|
// ejecuto el comando git
|
|
|
$output->writeln('Push de la rama.');
|
|
|
- $command = $cd_path . "; git push " . $optionRemoteGit . " --tags ";
|
|
|
+ $command = $cd_path . "; git push " . $optionRemoteGit . " --tags ";
|
|
|
$output->writeln("\t" . $command);
|
|
|
- // tengo que hacer el --tags para que pase todos los tags
|
|
|
+ // tengo que hacer el --tags para que pase todos los tags
|
|
|
shell_exec($command);
|
|
|
} catch (GitException $e) {
|
|
|
$output->writeln("SE PRODUJO UN ERROR EN " . $sec);
|
|
|
shell_exec($cd_path . "; git reset ");
|
|
|
$output->writeln($e->getTraceAsString());
|
|
|
$output->writeln($sec . ": " . $e->getMessage());
|
|
|
+
|
|
|
return $e->getCode();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
}
|