Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $git = new GitRepository($input->getArgument('docroot'));
     // Perform the merge.
     $git->checkout()->execute($input->getArgument('destination'));
     $git->merge()->execute($input->getArgument('source'), null, '--no-ff');
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $git = new GitRepository($input->getArgument('docroot'));
     if ($input->getOption('tags')) {
         $git->push()->tags()->execute($input->getArgument('remote'));
     } else {
         $git->push()->execute($input->getArgument('remote'), $input->getArgument('branch'));
     }
 }
Пример #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $git = new GitRepository($input->getArgument('docroot'));
     $branch = $input->getArgument('branch');
     if (!is_null($branch)) {
         $git->cloneRepository()->branch($input->getArgument('branch'))->execute($input->getArgument('clone'));
     } else {
         $git->cloneRepository()->execute($input->getArgument('clone'));
     }
 }
Пример #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Check out to an existing branch.
     $git = new GitRepository($input->getArgument('docroot'));
     if ($input->getOption('create')) {
         // Create a new branch, if specified.
         $git->checkout()->create()->execute($input->getArgument('branch'));
     } else {
         $git->checkout()->execute($input->getArgument('branch'));
     }
 }
Пример #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Add the file to the staging index.
     $git = new GitRepository($input->getArgument('docroot'));
     if (!is_null($input->getOption('all'))) {
         $git->add()->all()->execute();
     } else {
         if (!is_null($input->getArgument('file'))) {
             $git->add()->execute($input->getArgument('file'));
         }
     }
 }
Пример #6
0
 /**
  * Execute the command.
  *
  * @return mixed Depend on the command.
  *
  * @throws GitException When the command is executed the second time or could not be executed.
  */
 protected function run()
 {
     $process = $this->processBuilder->getProcess();
     if ($this->output !== null) {
         throw new GitException('Command cannot be executed twice', $process->getWorkingDirectory(), $process->getCommandLine(), $this->output, '');
     }
     $this->repository->getConfig()->getLogger()->debug(sprintf('[ccabs-repository-git] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()));
     if ($this->dryRun) {
         return $process->getCommandLine();
     }
     $process->run();
     $this->output = $process->getOutput();
     $this->output = rtrim($this->output, "\r\n");
     if (!$process->isSuccessful()) {
         throw GitException::createFromProcess('Could not execute git command', $process);
     }
     return $this->output;
 }
Пример #7
0
 /**
  * @covers \Bit3\GitPhp\GitRepository::tag
  * @covers \Bit3\GitPhp\Command\TagCommandBuilder::execute
  */
 public function testTagOnUninitializedRepository()
 {
     $this->setExpectedException('Bit3\\GitPhp\\GitException');
     $this->uninitializedGitRepository->tag()->execute('unit-test');
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $exitCode = 0;
     $git = new GitRepository($this->input->getArgument('git-dir'));
     $branches = $git->branch()->listBranches()->getNames();
     $composer = json_decode(file_get_contents($input->getArgument('git-dir') . '/composer.json'), true);
     if (!isset($composer['extra']['branch-alias'])) {
         if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->writeln('<info>No branch aliases found, skipping test.</info>');
         }
         return 0;
     }
     foreach ($composer['extra']['branch-alias'] as $branch => $alias) {
         $simpleBranch = $this->simplifyBranch($branch);
         if (!in_array($simpleBranch, $branches)) {
             if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
                 $output->writeln(sprintf('<info>Skipping non existing branch %s(%s)</info>', $branch, $alias));
             }
             continue;
         }
         $tag = $this->getTagFromBranch($simpleBranch);
         // No tag yet, therefore definately before any version.
         if ($tag === null) {
             $output->writeln(sprintf('<comment>Branch alias %s(%s) has not been tagged yet.</comment>', $branch, $alias));
         } elseif (!$this->validate($tag, $alias)) {
             $output->writeln(sprintf('<error>The branch alias %s(%s) is behind the latest branch tag %s!</error>', $branch, $alias, $tag));
             $exitCode = 1;
         } else {
             if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
                 $output->writeln(sprintf('<info>Branch alias %s(%s) is ahead of the latest branch tag.</info>', $branch, $alias));
             }
         }
     }
     return $exitCode;
 }
Пример #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $git = new GitRepository($input->getArgument('docroot'));
     $git->commit()->message($input->getArgument('message'))->execute();
 }
Пример #10
0
 /**
  * Retrieve the data of the current user on the system.
  *
  * @param GitRepository $git The repository to extract all files from.
  *
  * @return string
  *
  * @throws GitException When the git execution failed.
  */
 private function getCurrentUserInfo($git)
 {
     // Sadly no command in our git library for this.
     $processBuilder = new ProcessBuilder();
     $processBuilder->setWorkingDirectory($git->getRepositoryPath());
     $processBuilder->add($git->getConfig()->getGitExecutablePath())->add('config')->add('--get-regexp')->add('user.[name|email]');
     $process = $processBuilder->getProcess();
     $git->getConfig()->getLogger()->debug(sprintf('[git-php] exec [%s] %s', $process->getWorkingDirectory(), $process->getCommandLine()));
     $process->run();
     $output = rtrim($process->getOutput(), "\r\n");
     if (!$process->isSuccessful()) {
         throw GitException::createFromProcess('Could not execute git command', $process);
     }
     $config = array();
     foreach (explode(PHP_EOL, $output) as $line) {
         list($name, $value) = explode(' ', $line, 2);
         $config[trim($name)] = trim($value);
     }
     if (isset($config['user.name']) && $config['user.email']) {
         return sprintf('%s <%s>', $config['user.name'], $config['user.email']);
     }
     return '';
 }
Пример #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $git = new GitRepository($input->getArgument('docroot'));
     $current_tag = $git->describe()->tags()->execute();
     $output->writeln($current_tag);
 }