Ejemplo n.º 1
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn(["<comment>Loading directories to tag for: {$this->directory->getPath()}</comment>", '']);
     if ($this->directory->getSubdirectories()->isEmpty()) {
         $output->writeln('<error>No subdirectories found.</error>');
         return;
     }
     // Loop through all directories to search for repositories.
     foreach ($this->directory->getSubdirectories() as $subDirectory) {
         if ($input->getArgument('match') && !preg_match("/{$input->getArgument('match')}/", $subDirectory)) {
             continue;
         }
         // Instantiates package from directory.
         /** @var Package $package */
         $package = new Package($subDirectory);
         $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag));
         // files not committed?!
         if (!$input->getOption('force') && !$package->getChangesSinceLatestTag()) {
             $output->writeln('<comment>No commits detected since last tag, skipping.</comment>');
             continue;
         } else {
             $changes = $package->getChangesSinceLatestTag(false);
             if ($changes instanceof Collection) {
                 $changes->each(function ($item) use($output) {
                     $output->writeln($item);
                 });
             }
             $version = $this->askForVersion($input, $output, $package);
             if (empty($version)) {
                 $output->writeln('<comment>Skipped tagging, no version provided.</comment>');
                 continue;
             }
             if ($input->getOption('changelog')) {
                 $package->generateChangelog('changelogs', $package->latestTag, 'HEAD', $version);
                 $package->commit("Auto-generated changelog for {$version}.");
             }
             $package->addTag($version);
         }
         // Return to original path.
         chdir($this->directory->getCurrentPath());
     }
 }
Ejemplo n.º 2
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn(["<comment>Loading directories to pull for: {$this->directory->getPath()}</comment>", '']);
     if ($this->directory->getSubdirectories()->isEmpty()) {
         $output->writeln('<error>No subdirectories found.</error>');
         return;
     }
     // Loop through all directories to search for repositories.
     foreach ($this->directory->getSubdirectories() as $subDirectory) {
         $quotedMatch = preg_quote(rtrim($input->getArgument('match'), DIRECTORY_SEPARATOR));
         if ($input->getArgument('match') && !preg_match("/{$quotedMatch}/", $subDirectory)) {
             $output->writeln("<comment>Skipped {$subDirectory}</comment>");
             continue;
         }
         // Instantiates package from directory.
         $package = new Package($subDirectory);
         $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag));
         $package->push();
         // Return to original path.
         chdir($this->directory->getCurrentPath());
     }
 }
Ejemplo n.º 3
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn(["<comment>Verifying status for: {$this->directory->getPath()}</comment>", '']);
     if ($this->directory->getSubdirectories()->isEmpty()) {
         $output->writeln('<error>No subdirectories found.</error>');
         return;
     }
     // Loop through all directories to search for repositories.
     foreach ($this->directory->getSubdirectories() as $subDirectory) {
         if ($input->getArgument('match') && !preg_match("/{$input->getArgument('match')}/", $subDirectory)) {
             $output->writeln("<comment>Skipped {$subDirectory}</comment>");
             continue;
         }
         // Instantiates package from directory.
         $package = new Package($subDirectory);
         $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag));
         // Show commit status, open, added and new.
         $output->writeln($package->getCommitState());
         $output->writeln($package->getUnpushedCommitState());
         $output->writeln($package->getChangesSinceLatestTag());
         // Return to original path.
         chdir($this->directory->getCurrentPath());
     }
 }
Ejemplo n.º 4
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn(["<comment>Loading directories to pull for: {$this->directory->getPath()}</comment>", '']);
     if ($this->directory->getSubdirectories()->isEmpty()) {
         $output->writeln('<error>No subdirectories found.</error>');
         return;
     }
     // Loop through all directories to search for repositories.
     foreach ($this->directory->getSubdirectories() as $subDirectory) {
         $quotedMatch = preg_quote(rtrim($input->getArgument('match'), DIRECTORY_SEPARATOR));
         if ($input->getArgument('match') && !preg_match("/{$quotedMatch}/", $subDirectory)) {
             $output->writeln("<comment>Skipped {$subDirectory}</comment>");
             continue;
         }
         // Instantiates package from directory.
         $package = new Package($subDirectory);
         $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag));
         $stashed = false;
         // files not committed?!
         if (!$input->getOption('force') && !$input->getOption('stash') && $package->getCommitState()) {
             $output->writeln('<error>Local changes might be lost by pulling, commit/stash before continuing.</error>');
             continue;
         } else {
             if ($input->getOption('stash') && $package->getCommitState()) {
                 $package->stashChanges();
                 $stashed = true;
             }
             $package->pullLatestChanges();
             if ($input->getOption('stash') && $stashed) {
                 $package->restoreChanges();
             }
         }
         // Return to original path.
         chdir($this->directory->getCurrentPath());
     }
 }
Ejemplo n.º 5
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn(["<comment>Loading directories to create changelogs for: {$this->directory->getPath()}</comment>", '']);
     if ($this->directory->getSubdirectories()->isEmpty()) {
         $output->writeln('<error>No subdirectories found.</error>');
         return;
     }
     // Loop through all directories to search for repositories.
     foreach ($this->directory->getSubdirectories() as $subDirectory) {
         if ($input->getArgument('match') && !preg_match("/{$input->getArgument('match')}/", $subDirectory)) {
             continue;
         }
         /** @var Package $package */
         $package = new Package($subDirectory);
         $path = rtrim($input->getOption('path'), '/');
         $output->writeln(sprintf('<info>%s - version: %s</info>', $package->name, $package->latestTag));
         // attempt to create directory
         if (!is_dir($path)) {
             if (!mkdir($path, 0755, true)) {
                 $output->writeln("<error>Couldn't create directory {$path}</error>");
                 return;
             }
         }
         // files not committed?!
         if (!$input->getOption('force') && $package->getCommitState()) {
             $output->writeln('<error>Package has an unresolved commit state; please resolve before creating changelogs.</error>');
             continue;
         } else {
             $higherVersion = null;
             $aliasVersion = null;
             if ($input->getOption('head')) {
                 $higherVersion = 'HEAD';
                 $tags = [$package->latestTag];
                 $aliasVersion = $input->getOption('head');
             } else {
                 $tags = $package->getTags();
             }
             foreach ($tags as $version) {
                 if (!is_null($higherVersion)) {
                     if ($aliasVersion) {
                         $output->writeln("<info>Version {$version} - {$aliasVersion}</info>");
                     } else {
                         $output->writeln("<info>Version {$version} - {$higherVersion}</info>");
                     }
                     $changes = $package->getChangesBetween($version, $higherVersion, false);
                     if ($changes instanceof Collection) {
                         if ($aliasVersion) {
                             $fileName = "{$path}/{$version}..{$aliasVersion}";
                         } else {
                             $fileName = "{$path}/{$version}..{$higherVersion}";
                         }
                         if ($package->generateChangelog($path, $version, $higherVersion, $aliasVersion)) {
                             $output->writeln("{$changes->count()} lines of changelog written to {$fileName}");
                         }
                     }
                 }
                 $higherVersion = $version;
                 if ($input->getOption('commit')) {
                     $package->commit("Changelog added for {$version}.");
                 }
             }
         }
         // Return to original path.
         chdir($this->directory->getCurrentPath());
     }
 }