/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $wc_path = $this->getWorkingCopyPath(); $conflicts = $this->repositoryConnector->getWorkingCopyConflicts($wc_path); if ($conflicts) { throw new CommandException('Conflicts detected. Please resolve them before committing.'); } $working_copy_status = $this->repositoryConnector->getCompactWorkingCopyStatus($wc_path, false); if (!$working_copy_status) { throw new CommandException('Nothing to commit.'); } $commit_message = $this->buildCommitMessage($wc_path); $commit_message .= PHP_EOL . PHP_EOL . self::STOP_LINE . PHP_EOL . PHP_EOL . $working_copy_status; $edited_commit_message = $this->_editor->setDocumentName('commit_message')->setContent($commit_message)->launch(); $stop_line_pos = strpos($edited_commit_message, self::STOP_LINE); if ($stop_line_pos !== false) { $edited_commit_message = trim(substr($edited_commit_message, 0, $stop_line_pos)); } $this->io->writeln(array('<fg=white;options=bold>Commit message:</>', $edited_commit_message, '')); if (!$this->io->askConfirmation('Run "svn commit"', false)) { throw new CommandException('Commit aborted by user.'); } $tmp_file = tempnam(sys_get_temp_dir(), 'commit_message_'); file_put_contents($tmp_file, $edited_commit_message); $this->repositoryConnector->getCommand('commit', '{' . $wc_path . '} -F {' . $tmp_file . '}')->runLive(); unlink($tmp_file); $this->io->writeln('<info>Done</info>'); }
/** * {@inheritdoc} * * @throws CommandException When conflicts are detected. * @throws CommandException Working copy has no changes. * @throws CommandException User decides not to perform a commit. */ protected function execute(InputInterface $input, OutputInterface $output) { $wc_path = $this->getWorkingCopyPath(); $conflicts = $this->_workingCopyConflictTracker->getNewConflicts($wc_path); if ($conflicts) { throw new CommandException('Conflicts detected. Please resolve them before committing.'); } $changelist = $this->getChangelist($wc_path); $compact_working_copy_status = $this->repositoryConnector->getCompactWorkingCopyStatus($wc_path, $changelist); if (!$compact_working_copy_status) { throw new CommandException('Nothing to commit.'); } $commit_message = $this->_commitMessageBuilder->build($wc_path, $this->getMergeTemplate(), $changelist); $commit_message .= PHP_EOL . PHP_EOL . self::STOP_LINE . PHP_EOL . PHP_EOL . $compact_working_copy_status; $edited_commit_message = $this->_editor->setDocumentName('commit_message')->setContent($commit_message)->launch(); $stop_line_pos = strpos($edited_commit_message, self::STOP_LINE); if ($stop_line_pos !== false) { $edited_commit_message = trim(substr($edited_commit_message, 0, $stop_line_pos)); } $this->io->writeln(array('<fg=white;options=bold>Commit message:</>', $edited_commit_message, '')); if (!$this->io->askConfirmation('Run "svn commit"', false)) { throw new CommandException('Commit aborted by user.'); } $tmp_file = tempnam(sys_get_temp_dir(), 'commit_message_'); file_put_contents($tmp_file, $edited_commit_message); $arguments = array('-F {' . $tmp_file . '}'); if (strlen($changelist)) { $arguments[] = '--depth empty'; // Relative path used to make command line shorter. foreach (array_keys($this->repositoryConnector->getWorkingCopyStatus($wc_path, $changelist)) as $path) { $arguments[] = '{' . $path . '}'; } } else { $arguments[] = '{' . $wc_path . '}'; } $this->repositoryConnector->getCommand('commit', implode(' ', $arguments))->runLive(); $this->_workingCopyConflictTracker->erase($wc_path); unlink($tmp_file); $this->io->writeln('<info>Done</info>'); }
/** * Opens value editing. * * @param mixed $value Value. * * @return mixed */ protected function openEditor($value) { return $this->_editor->setDocumentName('config_setting_value')->setContent($value)->launch(); }