diff --git a/README.md b/README.md new file mode 100644 index 00000000..8a6e92dc --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# DeveloperToolsForXF2 + + Developer tools for XenForo 2 + + ## Features + + - Display order next to option group under Setup > Options + - Display order next to permission interface title and permission + - Developer Options under drop down menu for every add-on allows you to specify what the contents of LICENSE, .gitignore and README.md file should be + - Upon running CLI command `xf-addon:build-release [addon_id]` a new directory is added into the add-on directory named "_repo" which can be used for VCS (Version Control System) + + ## License + + This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/.gitignore b/upload/src/addons/TickTackk/DeveloperTools/.gitignore new file mode 100644 index 00000000..42b8a907 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/.gitignore @@ -0,0 +1,4 @@ +_releases +_data +hashes.json +/.idea/ \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AbstractCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AbstractCommandBuilder.php new file mode 100644 index 00000000..fdb1062a --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AbstractCommandBuilder.php @@ -0,0 +1,148 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +use TickTackk\DeveloperTools\Git\GitException; +use TickTackk\DeveloperTools\Git\GitRepository; +use Symfony\Component\Process\ProcessBuilder; + +/** + * Abstract command builder. + * + * @SuppressWarnings(PHPMD.NumberOfChildren) + */ +abstract class AbstractCommandBuilder implements CommandBuilderInterface +{ + /** + * The path to the git repository. + * + * @var GitRepository + */ + public $repository; + + /** + * The process builder in use. + * + * @var ProcessBuilder + */ + protected $processBuilder; + + /** + * The process output. + * + * @var null|string + */ + protected $output = null; + + /** + * Flag if we want to dry run. + * + * @var bool + */ + protected $dryRun = false; + + /** + * Constructor. + * + * @param GitRepository $repository The git repository to work on. + */ + public function __construct(GitRepository $repository) + { + $this->repository = $repository; + + $this->processBuilder = new ProcessBuilder(); + $this->processBuilder->setWorkingDirectory($repository->getRepositoryPath()); + $this->processBuilder->add($this->repository->getConfig()->getGitExecutablePath()); + + $this->initializeProcessBuilder(); + } + + /** + * Enable dry run. If dry run is enabled, the execute() method return the executed command. + * + * @return $this + */ + public function enableDryRun() + { + $this->dryRun = true; + return $this; + } + + /** + * Initialize the process builder. + * + * @return void + */ + protected function initializeProcessBuilder() + { + } + + /** + * Retrieve the output text. + * + * @return null|string + */ + public function getOutput() + { + return $this->output; + } + + /** + * 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; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AddCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AddCommandBuilder.php new file mode 100644 index 00000000..4742fd9a --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/AddCommandBuilder.php @@ -0,0 +1,184 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Add command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class AddCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('add'); + } + + /** + * Add the dry run option to the command line. + * + * @return AddCommandBuilder + */ + public function dryRun() + { + $this->processBuilder->add('--dry-run'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return AddCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return AddCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the patch option to the command line. + * + * @return AddCommandBuilder + */ + public function patch() + { + $this->processBuilder->add('--patch'); + return $this; + } + + /** + * Add the update option to the command line. + * + * @return AddCommandBuilder + */ + public function update() + { + $this->processBuilder->add('--update'); + return $this; + } + + /** + * Add the all option to the command line. + * + * @return AddCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the no-all option to the command line. + * + * @return AddCommandBuilder + */ + public function noAll() + { + $this->processBuilder->add('--no-all'); + return $this; + } + + /** + * Add the intent-to-add option to the command line. + * + * @return AddCommandBuilder + */ + public function intentToAdd() + { + $this->processBuilder->add('--intent-to-add'); + return $this; + } + + /** + * Add the refresh option to the command line. + * + * @return AddCommandBuilder + */ + public function refresh() + { + $this->processBuilder->add('--refresh'); + return $this; + } + + /** + * Add the ignore-errors option to the command line. + * + * @return AddCommandBuilder + */ + public function ignoreErrors() + { + $this->processBuilder->add('--ignore-errors'); + return $this; + } + + /** + * Add the ignore-missing option to the command line. + * + * @return AddCommandBuilder + */ + public function ignoreMissing() + { + $this->processBuilder->add('--ignore-missing'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $pathspec Optional path spec to add to the command line. + * + * @param null|string $_ More arguments to append to the command. + * + * @return mixed + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathspec = null, $_ = null) + { + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathspec) { + $this->processBuilder->add($pathspec); + } + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/BranchCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/BranchCommandBuilder.php new file mode 100644 index 00000000..b5aa37c3 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/BranchCommandBuilder.php @@ -0,0 +1,356 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Branch command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class BranchCommandBuilder extends AbstractCommandBuilder +{ + const WHEN_ALWAYS = 'always'; + + const WHEN_NEVER = 'never'; + + const WHEN_AUTO = 'auto'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('branch'); + } + + /** + * Add the D option to the command line. + * + * @return BranchCommandBuilder + */ + public function delete() + { + $this->processBuilder->add('-D'); + return $this; + } + + /** + * Add the create-reflog option to the command line. + * + * @return BranchCommandBuilder + */ + public function createReflog() + { + $this->processBuilder->add('--create-reflog'); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return BranchCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the M option to the command line. + * + * @param bool|string $oldName Optionally pass the old name. + * + * @return BranchCommandBuilder + */ + public function move($oldName = false) + { + $this->processBuilder->add('-M'); + if ($oldName) { + $this->processBuilder->add($oldName); + } + return $this; + } + + /** + * Add the color option to the command line. + * + * @param string $when When to use colors. + * + * @return BranchCommandBuilder + * + * @see BranchCommandBuilder::WHEN_ALWAYS + * @see BranchCommandBuilder::WHEN_NEVER + * @see BranchCommandBuilder::WHEN_AUTO. + */ + public function color($when) + { + $this->processBuilder->add('--color=' . $when); + return $this; + } + + /** + * Add the no-color option to the command line. + * + * @return BranchCommandBuilder + */ + public function noColor() + { + $this->processBuilder->add('--no-color'); + return $this; + } + + /** + * Add the column option to the command line. + * + * @param bool|string $options Optional options to use. + * + * @return BranchCommandBuilder + */ + public function column($options = false) + { + $this->processBuilder->add('--column' . ($options ? '=' . $options : '')); + return $this; + } + + /** + * Add the no-column option to the command line. + * + * @return BranchCommandBuilder + */ + public function noColumn() + { + $this->processBuilder->add('--no-column'); + return $this; + } + + /** + * Add the remotes option to the command line. + * + * @return BranchCommandBuilder + */ + public function remotes() + { + $this->processBuilder->add('--remotes'); + return $this; + } + + /** + * Add the all option to the command line. + * + * @return BranchCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the list option to the command line. + * + * @return BranchCommandBuilder + */ + public function listBranches() + { + $this->processBuilder->add('--list'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return BranchCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return BranchCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the abbrev option to the command line. + * + * @param int $length The length after which to cut. + * + * @return BranchCommandBuilder + */ + public function abbrev($length) + { + $this->processBuilder->add('--abbrev=' . $length); + return $this; + } + + /** + * Add the no-abbrev option to the command line. + * + * @return BranchCommandBuilder + */ + public function noAbbrev() + { + $this->processBuilder->add('--no-abbrev'); + return $this; + } + + /** + * Add the track option to the command line. + * + * @return BranchCommandBuilder + */ + public function track() + { + $this->processBuilder->add('--track'); + return $this; + } + + /** + * Add the no-track option to the command line. + * + * @return BranchCommandBuilder + */ + public function noTrack() + { + $this->processBuilder->add('--no-track'); + return $this; + } + + /** + * Add the set-upstream option to the command line. + * + * @return BranchCommandBuilder + */ + public function setUpstream() + { + $this->processBuilder->add('--set-upstream'); + return $this; + } + + /** + * Add the set-upstream-to option to the command line. + * + * @param string $upstream The upstream branch name. + * + * @return BranchCommandBuilder + */ + public function setUpstreamTo($upstream) + { + $this->processBuilder->add('--set-upstream-to=' . $upstream); + return $this; + } + + /** + * Add the unset-upstream option to the command line. + * + * @return BranchCommandBuilder + */ + public function unsetUpstream() + { + $this->processBuilder->add('--unset-upstream'); + return $this; + } + + /** + * Add the contains option to the command line. + * + * @param string $commit The commit hash. + * + * @return BranchCommandBuilder + */ + public function contains($commit) + { + $this->processBuilder->add('--contains')->add($commit); + return $this; + } + + /** + * Add the merged option to the command line. + * + * @param string $commit The commit hash. + * + * @return BranchCommandBuilder + */ + public function merged($commit) + { + $this->processBuilder->add('--merged')->add($commit); + return $this; + } + + /** + * Add the no-merged option to the command line. + * + * @param string $commit The commit hash. + * + * @return BranchCommandBuilder + */ + public function noMerged($commit) + { + $this->processBuilder->add('--no-merged')->add($commit); + return $this; + } + + /** + * Execute the command and return the result. + * + * @param null|string $branchName Optionally the branch name on which to work on. + * + * @return string + */ + public function execute($branchName = null) + { + if ($branchName) { + $this->processBuilder->add($branchName); + } + return parent::run(); + } + + /** + * Retrieve the branch names. + * + * @return string[] + */ + public function getNames() + { + $branches = $this->execute(); + $branches = explode("\n", $branches); + $branches = array_map( + function ($branch) { + return ltrim($branch, '*'); + }, + $branches + ); + $branches = array_map('trim', $branches); + $branches = array_filter($branches); + + return $branches; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CheckoutCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CheckoutCommandBuilder.php new file mode 100644 index 00000000..eaf6e9bf --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CheckoutCommandBuilder.php @@ -0,0 +1,243 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Checkout command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class CheckoutCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('checkout'); + } + + /** + * Add the quiet option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the ours option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function ours() + { + $this->processBuilder->add('--ours'); + return $this; + } + + /** + * Add the theirs option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function theirs() + { + $this->processBuilder->add('--theirs'); + return $this; + } + + /** + * Add the b option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function create() + { + $this->processBuilder->add('-b'); + return $this; + } + + /** + * Add the B option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function overwrite() + { + $this->processBuilder->add('-B'); + return $this; + } + + /** + * Add the track option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function track() + { + $this->processBuilder->add('--track'); + return $this; + } + + /** + * Add the no-track option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function noTrack() + { + $this->processBuilder->add('--no-track'); + return $this; + } + + /** + * Add the l option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function reflog() + { + $this->processBuilder->add('-l'); + return $this; + } + + /** + * Add the detach option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function detach() + { + $this->processBuilder->add('--detach'); + return $this; + } + + /** + * Add the orphan option to the command line. + * + * @param null|string $newBranch The name of the new orphan branch. + * + * @return CheckoutCommandBuilder + */ + public function orphan($newBranch = null) + { + $this->processBuilder->add('--orphan'); + if ($newBranch) { + $this->processBuilder->add($newBranch); + } + return $this; + } + + /** + * Add the ignore-skip-worktree-bits option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function ignoreSkipWorktreeBits() + { + $this->processBuilder->add('--ignore-skip-worktree-bits'); + return $this; + } + + /** + * Add the merge option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function merge() + { + $this->processBuilder->add('--merge'); + return $this; + } + + /** + * Add the conflict option to the command line. + * + * @param string $style The conflicht handler style. + * + * @return CheckoutCommandBuilder + */ + public function conflict($style) + { + $this->processBuilder->add('--conflict=' . $style); + return $this; + } + + /** + * Add the patch option to the command line. + * + * @return CheckoutCommandBuilder + */ + public function patch() + { + $this->processBuilder->add('--patch'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $branchOrTreeIsh Name of the branch or tree. + * + * @param null| $path Path to which check out. + * + * @param null|string $_ More optional arguments to append to the command. + * + * @return mixed + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($branchOrTreeIsh = null, $path = null, $_ = null) + { + if ($branchOrTreeIsh) { + $this->processBuilder->add($branchOrTreeIsh); + } + + $paths = func_get_args(); + array_shift($paths); + if (count($paths)) { + $this->processBuilder->add('--'); + foreach ($paths as $path) { + $this->processBuilder->add($path); + } + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CloneCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CloneCommandBuilder.php new file mode 100644 index 00000000..a5690351 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CloneCommandBuilder.php @@ -0,0 +1,290 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Clone command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class CloneCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('clone'); + } + + /** + * Add the local option to the command line. + * + * @return CloneCommandBuilder + */ + public function local() + { + $this->processBuilder->add('--local'); + return $this; + } + + /** + * Add the no-hardlinks option to the command line. + * + * @return CloneCommandBuilder + */ + public function noHardlinks() + { + $this->processBuilder->add('--no-hardlinks'); + return $this; + } + + /** + * Add the shared option to the command line. + * + * @return CloneCommandBuilder + */ + public function shared() + { + $this->processBuilder->add('--shared'); + return $this; + } + + /** + * Add the reference option to the command line. + * + * @param string $repository The repository name. + * + * @return CloneCommandBuilder + */ + public function reference($repository) + { + $this->processBuilder->add('--reference')->add($repository); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return CloneCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return CloneCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the progress option to the command line. + * + * @return CloneCommandBuilder + */ + public function progress() + { + $this->processBuilder->add('--progress'); + return $this; + } + + /** + * Add the no-checkout option to the command line. + * + * @return CloneCommandBuilder + */ + public function noCheckout() + { + $this->processBuilder->add('--no-checkout'); + return $this; + } + + /** + * Add the bare option to the command line. + * + * @return CloneCommandBuilder + */ + public function bare() + { + $this->processBuilder->add('--bare'); + return $this; + } + + /** + * Add the mirror option to the command line. + * + * @return CloneCommandBuilder + */ + public function mirror() + { + $this->processBuilder->add('--mirror'); + return $this; + } + + /** + * Add the origin option to the command line. + * + * @param string $name The name of the origin. + * + * @return CloneCommandBuilder + */ + public function origin($name) + { + $this->processBuilder->add('--origin')->add($name); + return $this; + } + + /** + * Add the branch option to the command line. + * + * @param string $name The branch name. + * + * @return CloneCommandBuilder + */ + public function branch($name) + { + $this->processBuilder->add('--branch')->add($name); + return $this; + } + + /** + * Add the upload-pack option to the command line. + * + * @param string $uploadPack The upload pack. + * + * @return CloneCommandBuilder + */ + public function uploadPack($uploadPack) + { + $this->processBuilder->add('--upload-pack')->add($uploadPack); + return $this; + } + + /** + * Add the template option to the command line. + * + * @param string $templateDirectory The template directory. + * + * @return CloneCommandBuilder + */ + public function template($templateDirectory) + { + $this->processBuilder->add('--template=' . $templateDirectory); + return $this; + } + + /** + * Add the config option to the command line. + * + * @param string $key The config key. + * + * @param string $value The config value. + * + * @return CloneCommandBuilder + */ + public function config($key, $value) + { + $this->processBuilder->add('--config')->add($key . '=' . $value); + return $this; + } + + /** + * Add the depth option to the command line. + * + * @param string $depth The depth. + * + * @return CloneCommandBuilder + */ + public function depth($depth) + { + $this->processBuilder->add('--depth')->add($depth); + return $this; + } + + /** + * Add the no-single-branch option to the command line. + * + * @return CloneCommandBuilder + */ + public function noSingleBranch() + { + $this->processBuilder->add('--no-single-branch'); + return $this; + } + + /** + * Add the single-branch option to the command line. + * + * @return CloneCommandBuilder + */ + public function singleBranch() + { + $this->processBuilder->add('--single-branch'); + return $this; + } + + /** + * Add the option to the command line. + * + * @return CloneCommandBuilder + */ + public function recursive() + { + $this->processBuilder->add('--recursive'); + return $this; + } + + /** + * Add the separate-git-dir option to the command line. + * + * @param string $gitDir The git dir to use. + * + * @return CloneCommandBuilder + */ + public function separateGitDir($gitDir) + { + $this->processBuilder->add('--separate-git-dir=' . $gitDir); + return $this; + } + + /** + * Execute the command and return the result. + * + * @param string $repositoryUrl The url of the repository. + * + * @return mixed + */ + public function execute($repositoryUrl) + { + $this->processBuilder->add($repositoryUrl); + $this->processBuilder->add($this->repository->getRepositoryPath()); + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommandBuilderInterface.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommandBuilderInterface.php new file mode 100644 index 00000000..6ee06ecf --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommandBuilderInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Command builder interface. + */ +interface CommandBuilderInterface +{ +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommitCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommitCommandBuilder.php new file mode 100644 index 00000000..4618c5ec --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/CommitCommandBuilder.php @@ -0,0 +1,470 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Commit command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class CommitCommandBuilder extends AbstractCommandBuilder +{ + const CLEANUP_STRIP = 'strip'; + + const CLEANUP_WHITESPACE = 'whitespace'; + + const CLEANUP_VERBATIM = 'verbatim'; + + const CLEANUP_DEFAULT = 'default'; + + const UNTRACKED_FILES_NO = 'no'; + + const UNTRACKED_FILES_NORMAL = 'normal'; + + const UNTRACKED_FILES_ALL = 'all'; + + /** + * Flag determining if gpg signing is desired. + * + * @var bool + */ + protected $gpgSignIsset = false; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('commit'); + } + + /** + * Add the option to the command line. + * + * @return CommitCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the patch option to the command line. + * + * @return CommitCommandBuilder + */ + public function patch() + { + $this->processBuilder->add('--patch'); + return $this; + } + + /** + * Add the reuse-message option to the command line. + * + * @param string $commit The commit from which the message should be reused. + * + * @return CommitCommandBuilder + */ + public function reuseMessage($commit) + { + $this->processBuilder->add('--reuse-message=' . $commit); + return $this; + } + + /** + * Add the fixup option to the command line. + * + * @param string $commit The commit to fixup. + * + * @return CommitCommandBuilder + */ + public function fixup($commit) + { + $this->processBuilder->add('--fixup=' . $commit); + return $this; + } + + /** + * Add the squash option to the command line. + * + * @param string $commit The commit to squash. + * + * @return CommitCommandBuilder + */ + public function squash($commit) + { + $this->processBuilder->add('--squash=' . $commit); + return $this; + } + + /** + * Add the reset-author option to the command line. + * + * @return CommitCommandBuilder + */ + public function resetAuthor() + { + $this->processBuilder->add('--reset-author'); + return $this; + } + + /** + * Add the short option to the command line. + * + * @return CommitCommandBuilder + */ + public function short() + { + $this->processBuilder->add('--short'); + return $this; + } + + /** + * Add the branch option to the command line. + * + * @return CommitCommandBuilder + */ + public function branch() + { + $this->processBuilder->add('--branch'); + return $this; + } + + /** + * Add the porcelain option to the command line. + * + * @return CommitCommandBuilder + */ + public function porcelain() + { + $this->processBuilder->add('--porcelain'); + return $this; + } + + /** + * Add the long option to the command line. + * + * @return CommitCommandBuilder + */ + public function long() + { + $this->processBuilder->add('--long'); + return $this; + } + + /** + * Add the null option to the command line. + * + * @return CommitCommandBuilder + */ + public function null() + { + $this->processBuilder->add('--null'); + return $this; + } + + /** + * Add the file option to the command line. + * + * @param string $file The file. + * + * @return CommitCommandBuilder + */ + public function file($file) + { + $this->processBuilder->add('--file=' . $file); + return $this; + } + + /** + * Add the author option to the command line. + * + * @param string $author The author to use. + * + * @return CommitCommandBuilder + */ + public function author($author) + { + $this->processBuilder->add('--author=' . $author); + return $this; + } + + /** + * Add the date option to the command line. + * + * @param \DateTime|string $date The timestamp to use for the commit (if string: Y-m-d H:i:s). + * + * @return CommitCommandBuilder + */ + public function date($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--date=' . $date); + return $this; + } + + /** + * Add the message option to the command line. + * + * @param string $message The message to use. + * + * @return CommitCommandBuilder + */ + public function message($message) + { + $this->processBuilder->add('--message=' . $message); + return $this; + } + + /** + * Add the template option to the command line. + * + * @param string $file The template file. + * + * @return CommitCommandBuilder + */ + public function template($file) + { + $this->processBuilder->add('--template=' . $file); + return $this; + } + + /** + * Add the signoff option to the command line. + * + * @return CommitCommandBuilder + */ + public function signoff() + { + $this->processBuilder->add('--signoff'); + return $this; + } + + /** + * Add the no-verify option to the command line. + * + * @return CommitCommandBuilder + */ + public function noVerity() + { + $this->processBuilder->add('--no-verify'); + return $this; + } + + /** + * Add the allow-empty option to the command line. + * + * @return CommitCommandBuilder + */ + public function allowEmpty() + { + $this->processBuilder->add('--allow-empty'); + return $this; + } + + /** + * Add the allow-empty-message option to the command line. + * + * @return CommitCommandBuilder + */ + public function allowEmptyMessage() + { + $this->processBuilder->add('--allow-empty-message'); + return $this; + } + + /** + * Add the cleanup option to the command line. + * + * @param string $mode The cleanup mode. + * + * @return CommitCommandBuilder + */ + public function cleanup($mode) + { + $this->processBuilder->add('--cleanup=' . $mode); + return $this; + } + + /** + * Add the amend option to the command line. + * + * @return CommitCommandBuilder + */ + public function amend() + { + $this->processBuilder->add('--amend'); + return $this; + } + + /** + * Add the no-post-rewrite option to the command line. + * + * @return CommitCommandBuilder + */ + public function noPostRewrite() + { + $this->processBuilder->add('--no-post-rewrite'); + return $this; + } + + /** + * Add the include option to the command line. + * + * @return CommitCommandBuilder + */ + public function includ() + { + $this->processBuilder->add('--include'); + return $this; + } + + /** + * Add the only option to the command line. + * + * @return CommitCommandBuilder + */ + public function only() + { + $this->processBuilder->add('--only'); + return $this; + } + + /** + * Add the untracked-files option to the command line. + * + * @param null|string $mode How to handle untracked files. + * + * @return CommitCommandBuilder + */ + public function untrackedFiles($mode = null) + { + $this->processBuilder->add('--untracked-files' . ($mode ? '=' . $mode : '')); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return CommitCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return CommitCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the dry-run option to the command line. + * + * @return CommitCommandBuilder + */ + public function dryRun() + { + $this->processBuilder->add('--dry-run'); + return $this; + } + + /** + * Add the status option to the command line. + * + * @return CommitCommandBuilder + */ + public function status() + { + $this->processBuilder->add('--status'); + return $this; + } + + /** + * Add the no-status option to the command line. + * + * @return CommitCommandBuilder + */ + public function noStatus() + { + $this->processBuilder->add('--no-status'); + return $this; + } + + /** + * Add the option to the command line. + * + * @param null|string $keyId Optional id of the GPG key to use. + * + * @return CommitCommandBuilder + */ + public function gpgSign($keyId = null) + { + $this->gpgSignIsset = true; + $this->processBuilder->add('--gpg-sign' . ($keyId ? '=' . $keyId : '')); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null| $pathspec Path to commit. + * + * @param null|string $_ More optional pathes to commit. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathspec = null, $_ = null) + { + // prevent launching the editor + $this->processBuilder->add('--no-edit'); + + if (!$this->gpgSignIsset && $this->repository->getConfig()->isSignCommitsEnabled()) { + $this->gpgSign($this->repository->getConfig()->getSignCommitUser()); + } + + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathspec) { + $this->processBuilder->add($pathspec); + } + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ConfigCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ConfigCommandBuilder.php new file mode 100644 index 00000000..0aea0640 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ConfigCommandBuilder.php @@ -0,0 +1,376 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Matthew Gamble + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Config command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class ConfigCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('config'); + } + + /** + * Specify a single config file that should be looked at. + * Has special support for the global, system and local flags. + * + * @param string $file The config file to use. + * + * @return ConfigCommandBuilder + */ + public function file($file) + { + if (in_array($file, array('global', 'system', 'local'))) { + $this->processBuilder->add('--' . $file); + } else { + $this->processBuilder->add('--file') + ->add($file); + } + return $this; + } + + /** + * Add the blob option to the command line. + * + * See "SPECIFYING REVISIONS" section in gitrevisions(7) for a list of ways to spell blob names. + * + * @param string $blobId The blob id to use. + * + * @return ConfigCommandBuilder + */ + public function blob($blobId) + { + $this->processBuilder->add('--blob ' . $blobId); + return $this; + } + + /** + * Add a type option to the command line. + * + * @param string $type The type name. + * + * @return ConfigCommandBuilder + * + * @throws \InvalidArgumentException When an invalid type name is encountered. + */ + public function type($type) + { + if (in_array($type, array('bool', 'int', 'bool-or-int', 'path'))) { + $this->processBuilder->add('--' . $type); + } else { + throw new \InvalidArgumentException('Invalid configuration type supplied.'); + } + return $this; + } + + /** + * Add the add option and associated parameters to the command line. + * + * @param string $name The config value name. + * + * @param string $value The value to use. + * + * @return ConfigCommandBuilder + */ + public function add($name, $value) + { + $this->processBuilder->add('--add') + ->add($name) + ->add($value); + return $this; + } + + /** + * Add the replace-all option and associated parameters to the command line. + * + * @param string $name The config value name. + * + * @param string $value The value to use. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function replaceAll($name, $value, $valueRegex = null) + { + $this->processBuilder->add('--replace-all') + ->add($name) + ->add($value); + if ($valueRegex !== null) { + $this->processBuilder->add($valueRegex); + } + return $this; + } + + /** + * Adds the NUL byte termination option to the command line. + * + * @return ConfigCommandBuilder + */ + public function terminateWithNUL() + { + $this->processBuilder->add('--null'); + return $this; + } + + /** + * Add the get option and associated parameters to the command line. + * + * @param string $name The config value name. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function get($name, $valueRegex = null) + { + $this->processBuilder->add('--get'); + $this->addNameAndPattern($name, $valueRegex); + return $this; + } + + /** + * Add the get-all option and associated parameters to the command line. + * + * @param string $name The config value name. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function getAll($name, $valueRegex = null) + { + $this->processBuilder->add('--get-all'); + $this->addNameAndPattern($name, $valueRegex); + return $this; + } + + /** + * Add the get-regexp option and associated parameters to the command line. + * + * @param string $nameRegex The config name regex. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function getRegexp($nameRegex, $valueRegex = null) + { + $this->processBuilder->add('--get-regexp'); + $this->addNameAndPattern($nameRegex, $valueRegex); + return $this; + } + + /** + * Add the get-urlmatch option and associated parameters to the command line. + * + * @param string $name The config name. + * + * @param string $url The url to match. + * + * @return ConfigCommandBuilder + */ + public function getUrlmatch($name, $url) + { + $this->processBuilder->add('--get-urlmatch'); + $this->addNameAndPattern($name, $url); + return $this; + } + + /** + * Add the unset option and associated parameters to the command line. + * + * @param string $name The name of the config value to unset. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function unsetOpt($name, $valueRegex = null) + { + $this->processBuilder->add('--unset'); + $this->addNameAndPattern($name, $valueRegex); + return $this; + } + + /** + * Add the unset-all option and associated parameters to the command line. + * + * @param string $name The name of the config value to unset. + * + * @param null|string $valueRegex The value regex to use. + * + * @return ConfigCommandBuilder + */ + public function unsetAll($name, $valueRegex = null) + { + $this->processBuilder->add('--unset-all'); + $this->addNameAndPattern($name, $valueRegex); + return $this; + } + + /** + * Add the passed name and the passed pattern if not null. + * + * @param string $name The name to add. + * + * @param null|string $pattern The pattern to add (if not null). + * + * @return void + */ + private function addNameAndPattern($name, $pattern) + { + $this->processBuilder->add($name); + if ($pattern !== null) { + $this->processBuilder->add($pattern); + } + } + + /** + * Add the rename-section option and associated parameters to the command line. + * + * @param string $oldName The old section name. + * + * @param string $newName The new section name. + * + * @return ConfigCommandBuilder + */ + public function renameSection($oldName, $newName) + { + $this->processBuilder->add('--rename-section') + ->add($oldName) + ->add($newName); + return $this; + } + + /** + * Add the remove-section option to the command line. + * + * @param string $name The section name. + * + * @return ConfigCommandBuilder + */ + public function removeSection($name) + { + $this->processBuilder->add('--remove-section') + ->add($name); + return $this; + } + + /** + * Add the list option to the command line. + * + * @return ConfigCommandBuilder + */ + public function listOpt() + { + $this->processBuilder->add('--list'); + return $this; + } + + /** + * Add the get-color option and associated parameters to the command line. + * + * @param string $name The name of the color to retrieve. + * + * @param null|string $default The default value to return. + * + * @return ConfigCommandBuilder + */ + public function getColor($name, $default = null) + { + $this->processBuilder->add('--get-color') + ->add($name); + if ($default !== null) { + $this->processBuilder->add($default); + } + return $this; + } + + /** + * Add the get-colorbool option and associated parameters to the command line. + * + * @param string $name The name of the color to check. + * + * @param bool|null $stdoutIsTty Flag if stdout is a tty. + * + * @return ConfigCommandBuilder + */ + public function getColorBool($name, $stdoutIsTty = null) + { + $this->processBuilder->add('--get-colorbool') + ->add($name); + if (is_bool($stdoutIsTty)) { + $this->processBuilder->add($stdoutIsTty ? 'true' : 'false'); + } + return $this; + } + + /** + * Add the includes or no-includes option to the command line. + * + * @param bool $allow Flag if include.* directives in config files shall be respected when looking up values. + * + * @return ConfigCommandBuilder + */ + public function includes($allow = true) + { + $this->processBuilder->add($allow ? '--includes' : '--no-includes'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $name Pass name of setting here to perform a basic get or set operation. + * + * @param null|string $value Pass a value for the setting to turn this into a set command. + * + * @param null|string $valueRegex Pass a regex to limit changing of a multi-value setting to certain settings. + * + * @return mixed + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($name = null, $value = null, $valueRegex = null) + { + if ($name !== null) { + $this->processBuilder->add($name); + if ($value !== null) { + $this->processBuilder->add($value); + if ($valueRegex !== null) { + $this->processBuilder->add($valueRegex); + } + } + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/DescribeCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/DescribeCommandBuilder.php new file mode 100644 index 00000000..6ac492c8 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/DescribeCommandBuilder.php @@ -0,0 +1,198 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Describe command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class DescribeCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('describe'); + } + + /** + * Add the dirty option to the command line. + * + * @param bool|string $mark The mark to use. + * + * @return DescribeCommandBuilder + */ + public function dirty($mark = false) + { + $this->processBuilder->add('--dirty'); + if ($mark) { + $this->processBuilder->add($mark); + } + return $this; + } + + /** + * Add the all option to the command line. + * + * @return DescribeCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @return DescribeCommandBuilder + */ + public function tags() + { + $this->processBuilder->add('--tags'); + return $this; + } + + /** + * Add the contains option to the command line. + * + * @return DescribeCommandBuilder + */ + public function contains() + { + $this->processBuilder->add('--contains'); + return $this; + } + + /** + * Add the abbrev option to the command line. + * + * @param int $n Chars after which to abbreviate. + * + * @return DescribeCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortVariableName) + */ + public function abbrev($n) + { + $this->processBuilder->add('--abbrev=' . $n); + return $this; + } + + /** + * Add the candidates option to the command line. + * + * @param int $n Amount of candidates. + * + * @return DescribeCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortVariableName) + */ + public function candidates($n) + { + $this->processBuilder->add('--candidates=' . $n); + return $this; + } + + /** + * Add the exact-match option to the command line. + * + * @return DescribeCommandBuilder + */ + public function exactMatch() + { + $this->processBuilder->add('--exact-match'); + return $this; + } + + /** + * Add the debug option to the command line. + * + * @return DescribeCommandBuilder + */ + public function debug() + { + $this->processBuilder->add('--debug'); + return $this; + } + + /** + * Add the long option to the command line. + * + * @return DescribeCommandBuilder + */ + public function long() + { + $this->processBuilder->add('--long'); + return $this; + } + + /** + * Add the match option to the command line. + * + * @param string $pattern The pattern to use for filtering. + * + * @return DescribeCommandBuilder + */ + public function match($pattern) + { + $this->processBuilder->add('--match')->add($pattern); + return $this; + } + + /** + * Add the always option to the command line. + * + * @return DescribeCommandBuilder + */ + public function always() + { + $this->processBuilder->add('--always'); + return $this; + } + + /** + * Add the first-parent option to the command line. + * + * @return DescribeCommandBuilder + */ + public function firstParent() + { + $this->processBuilder->add('--first-parent'); + return $this; + } + + /** + * Execute the command and return the result. + * + * @param string $commit The commit to describe (defaults to HEAD). + * + * @return string + */ + public function execute($commit = 'HEAD') + { + $this->processBuilder->add($commit); + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/FetchCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/FetchCommandBuilder.php new file mode 100644 index 00000000..703cc12d --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/FetchCommandBuilder.php @@ -0,0 +1,302 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Fetch command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class FetchCommandBuilder extends AbstractCommandBuilder +{ + const RECURSE_SUBMODULES_YES = 'yes'; + + const RECURSE_SUBMODULES_ON_DEMAND = 'on-demand'; + + const RECURSE_SUBMODULES_NO = 'no'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('fetch'); + } + + /** + * Add the all option to the command line. + * + * @return FetchCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the append option to the command line. + * + * @return FetchCommandBuilder + */ + public function append() + { + $this->processBuilder->add('--append'); + return $this; + } + + /** + * Add the depth option to the command line. + * + * @param int $depth The commit depth to use. + * + * @return FetchCommandBuilder + */ + public function depth($depth) + { + $this->processBuilder->add('--depth=' . $depth); + return $this; + } + + /** + * Add the unshallow option to the command line. + * + * @return FetchCommandBuilder + */ + public function unshallow() + { + $this->processBuilder->add('--unshallow'); + return $this; + } + + /** + * Add the update-shallow option to the command line. + * + * @return FetchCommandBuilder + */ + public function updateShallow() + { + $this->processBuilder->add('--update-shallow'); + return $this; + } + + /** + * Add the dry-run option to the command line. + * + * @return FetchCommandBuilder + */ + public function dryRun() + { + $this->processBuilder->add('--dry-run'); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return FetchCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the keep option to the command line. + * + * @return FetchCommandBuilder + */ + public function keep() + { + $this->processBuilder->add('--keep'); + return $this; + } + + /** + * Add the multiple option to the command line. + * + * @return FetchCommandBuilder + */ + public function multiple() + { + $this->processBuilder->add('--multiple'); + return $this; + } + + /** + * Add the prune option to the command line. + * + * @return FetchCommandBuilder + */ + public function prune() + { + $this->processBuilder->add('--prune'); + return $this; + } + + /** + * Add the no-tags option to the command line. + * + * @return FetchCommandBuilder + */ + public function noTags() + { + $this->processBuilder->add('--no-tags'); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @return FetchCommandBuilder + */ + public function tags() + { + $this->processBuilder->add('--tags'); + return $this; + } + + /** + * Add the recurse-submodules option to the command line. + * + * @param bool|string $recurse The value. + * + * @return FetchCommandBuilder + */ + public function recurseSubmodules($recurse = false) + { + $this->processBuilder->add('--recurse-submodules' . ($recurse ? '=' . $recurse : '')); + return $this; + } + + /** + * Add the no-recurse-submodules option to the command line. + * + * @return FetchCommandBuilder + */ + public function noRecurseSubmodules() + { + $this->processBuilder->add('--no-recurse-submodules'); + return $this; + } + + /** + * Add the submodule-prefix option to the command line. + * + * @param string $path The path. + * + * @return FetchCommandBuilder + */ + public function submodulePrefix($path) + { + $this->processBuilder->add('--submodule-prefix=' . $path); + return $this; + } + + /** + * Add the recurse-submodules-default option to the command line. + * + * @param string $recurse The value. + * + * @return FetchCommandBuilder + */ + public function recurseSubmodulesDefault($recurse) + { + $this->processBuilder->add('--recurse-submodules-default=' . $recurse); + return $this; + } + + /** + * Add the update-head-ok option to the command line. + * + * @return FetchCommandBuilder + */ + public function updateHeadOk() + { + $this->processBuilder->add('--update-head-ok'); + return $this; + } + + /** + * Add the upload-pack option to the command line. + * + * @param string $uploadPack The pack. + * + * @return FetchCommandBuilder + */ + public function uploadPack($uploadPack) + { + $this->processBuilder->add('--upload-pack')->add($uploadPack); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return FetchCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return FetchCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param string $repository Name of the remote to use (Defaults to origin). + * + * @param null|string $refspec Refspec to fetch. + * + * @param null|string $_ More optional refspecs to commit. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($repository = 'origin', $refspec = null, $_ = null) + { + $this->processBuilder->add($repository); + + $refspecs = func_get_args(); + array_shift($refspecs); + foreach ($refspecs as $refspec) { + $this->processBuilder->add($refspec); + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/InitCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/InitCommandBuilder.php new file mode 100644 index 00000000..5c89d53c --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/InitCommandBuilder.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Init command builder. + */ +class InitCommandBuilder extends AbstractCommandBuilder +{ + const SHARE_FALSE = 'false'; + + const SHARE_TRUE = 'true'; + + const SHARE_UMASK = 'umask'; + + const SHARE_GROUP = 'group'; + + const SHARE_ALL = 'all'; + + const SHARE_WORLD = 'world'; + + const SHARE_EVERYBODY = 'everybody'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('init'); + } + + /** + * Add the quiet option to the command line. + * + * @return FetchCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the bare option to the command line. + * + * @return FetchCommandBuilder + */ + public function bare() + { + $this->processBuilder->add('--bare'); + return $this; + } + + /** + * Add the template option to the command line. + * + * @param string $templateDirectory Path to the template directory. + * + * @return FetchCommandBuilder + */ + public function template($templateDirectory) + { + $this->processBuilder->add('--template=' . $templateDirectory); + return $this; + } + + /** + * Add the separate-git-dir option to the command line. + * + * @param string $gitDir Path to the .git dir. + * + * @return FetchCommandBuilder + */ + public function separateGitDir($gitDir) + { + $this->processBuilder->add('--separate-git-dir=' . $gitDir); + return $this; + } + + /** + * Add the shared option to the command line. + * + * @param string $share The share value. + * + * @return FetchCommandBuilder + */ + public function shared($share) + { + $this->processBuilder->add('--shared=' . $share); + return $this; + } + + /** + * Execute the command and return the output. + * + * @return string + */ + public function execute() + { + $this->processBuilder->add($this->repository->getRepositoryPath()); + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LogCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LogCommandBuilder.php new file mode 100644 index 00000000..51908adb --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LogCommandBuilder.php @@ -0,0 +1,1086 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Log command builder. + * + * @SuppressWarnings(PHPMD.ExcessiveClassLength) + * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class LogCommandBuilder extends AbstractCommandBuilder +{ + const DECORATE_SHORT = 'short'; + + const DECORATE_FULL = 'full'; + + const DECORATE_NO = 'no'; + + const WALK_SORTED = 'sorted'; + + const WALK_UNSORTED = 'unsorted'; + + const DATE_RELATIVE = 'relative'; + + const DATE_LOCAL = 'local'; + + const DATE_DEFAULT = 'default'; + + const DATE_ISO = 'iso'; + + const DATE_RFC = 'rfc'; + + const DATE_SHORT = 'short'; + + const DATE_RAW = 'raw'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('log'); + } + + /** + * Add the follow option to the command line. + * + * @return LogCommandBuilder + */ + public function follow() + { + $this->processBuilder->add('--follow'); + return $this; + } + + /** + * Add the no-decorate option to the command line. + * + * @return LogCommandBuilder + */ + public function noDecorate() + { + $this->processBuilder->add('--no-decorate'); + return $this; + } + + /** + * Add the decorate option to the command line. + * + * @param string $decorate The decorator value to use. + * + * @return LogCommandBuilder + */ + public function decorate($decorate) + { + $this->processBuilder->add('--decorate' . ($decorate ? '=' . $decorate : '')); + return $this; + } + + /** + * Add the source option to the command line. + * + * @return LogCommandBuilder + */ + public function source() + { + $this->processBuilder->add('--source'); + return $this; + } + + /** + * Add the use-mailmap option to the command line. + * + * @return LogCommandBuilder + */ + public function useMailmap() + { + $this->processBuilder->add('--use-mailmap'); + return $this; + } + + /** + * Add the full-diff option to the command line. + * + * @return LogCommandBuilder + */ + public function fullDiff() + { + $this->processBuilder->add('--full-diff'); + return $this; + } + + /** + * Add the log-size option to the command line. + * + * @return LogCommandBuilder + */ + public function logSize() + { + $this->processBuilder->add('--log-size'); + return $this; + } + + /** + * Add the option to the command line. + * + * @param string $revisionRange The revision range. + * + * @return LogCommandBuilder + */ + public function revisionRange($revisionRange) + { + $this->processBuilder->add($revisionRange); + return $this; + } + + /** + * Add the max-count option to the command line. + * + * @param int $number Amount of log entries. + * + * @return LogCommandBuilder + */ + public function maxCount($number) + { + $this->processBuilder->add('--max-count=' . $number); + return $this; + } + + /** + * Add the skip option to the command line. + * + * @param int $number Amount of entries to skip. + * + * @return LogCommandBuilder + */ + public function skip($number) + { + $this->processBuilder->add('--skip=' . $number); + return $this; + } + + /** + * Add the since option to the command line. + * + * @param \DateTime|string $date The date from which on the commits shall be listed. + * + * @return LogCommandBuilder + */ + public function since($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--since=' . $date); + return $this; + } + + /** + * Add the after option to the command line. + * + * @param \DateTime|string $date The date after which the commits shall be listed. + * + * @return LogCommandBuilder + */ + public function after($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--after=' . $date); + return $this; + } + + /** + * Add the until option to the command line. + * + * @param \DateTime|string $date The date until which the commits shall be listed. + * + * @return LogCommandBuilder + */ + public function until($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--until=' . $date); + return $this; + } + + /** + * Add the before option to the command line. + * + * @param \DateTime|string $date The date before which the commits shall be listed. + * + * @return LogCommandBuilder + */ + public function before($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--before=' . $date); + return $this; + } + + /** + * Add the author option to the command line. + * + * @param string $pattern The pattern the author has to match. + * + * @return LogCommandBuilder + */ + public function author($pattern) + { + $this->processBuilder->add('--author=' . $pattern); + return $this; + } + + /** + * Add the grep-reflog option to the command line. + * + * @param string $pattern The pattern to grep the ref log with. + * + * @return LogCommandBuilder + */ + public function grepReflog($pattern) + { + $this->processBuilder->add('--grep-reflog=' . $pattern); + return $this; + } + + /** + * Add the grep option to the command line. + * + * @param string $pattern The pattern. + * + * @return LogCommandBuilder + */ + public function grep($pattern) + { + $this->processBuilder->add('--grep=' . $pattern); + return $this; + } + + /** + * Add the all-match option to the command line. + * + * @return LogCommandBuilder + */ + public function allMatch() + { + $this->processBuilder->add('--all-match'); + return $this; + } + + /** + * Add the regexp-ignore-case option to the command line. + * + * @return LogCommandBuilder + */ + public function regexpIgnoreCase() + { + $this->processBuilder->add('--regexp-ignore-case'); + return $this; + } + + /** + * Add the basicRegexp option to the command line. + * + * @return LogCommandBuilder + */ + public function basicRegexp() + { + $this->processBuilder->add('--basicRegexp'); + return $this; + } + + /** + * Add the extended-regexp option to the command line. + * + * @return LogCommandBuilder + */ + public function extendedRegexp() + { + $this->processBuilder->add('--extended-regexp'); + return $this; + } + + /** + * Add the fixed-strings option to the command line. + * + * @return LogCommandBuilder + */ + public function fixedStrings() + { + $this->processBuilder->add('--fixed-strings'); + return $this; + } + + /** + * Add the perl-regexp option to the command line. + * + * @return LogCommandBuilder + */ + public function perlRegexp() + { + $this->processBuilder->add('--perl-regexp'); + return $this; + } + + /** + * Add the remove-empty option to the command line. + * + * @return LogCommandBuilder + */ + public function removeEmpty() + { + $this->processBuilder->add('--remove-empty'); + return $this; + } + + /** + * Add the merges option to the command line. + * + * @return LogCommandBuilder + */ + public function merges() + { + $this->processBuilder->add('--merges'); + return $this; + } + + /** + * Add the no-merges option to the command line. + * + * @return LogCommandBuilder + */ + public function noMerges() + { + $this->processBuilder->add('--no-merges'); + return $this; + } + + /** + * Add the min-parents option to the command line. + * + * @param int $number The minimum amount of parents. + * + * @return LogCommandBuilder + */ + public function minParents($number) + { + $this->processBuilder->add('--min-parents=' . $number); + return $this; + } + + /** + * Add the max-parents option to the command line. + * + * @param int $number The maximum amount of parents. + * + * @return LogCommandBuilder + */ + public function maxParents($number) + { + $this->processBuilder->add('--max-parents=' . $number); + return $this; + } + + /** + * Add the no-min-parents option to the command line. + * + * @return LogCommandBuilder + */ + public function noMinParents() + { + $this->processBuilder->add('--no-min-parents'); + return $this; + } + + /** + * Add the no-max-parents option to the command line. + * + * @return LogCommandBuilder + */ + public function noMaxParents() + { + $this->processBuilder->add('--no-max-parents'); + return $this; + } + + /** + * Add the first-parent option to the command line. + * + * @return LogCommandBuilder + */ + public function firstParent() + { + $this->processBuilder->add('--first-parent'); + return $this; + } + + /** + * Add the not option to the command line. + * + * @return LogCommandBuilder + */ + public function not() + { + $this->processBuilder->add('--not'); + return $this; + } + + /** + * Add the all option to the command line. + * + * @return LogCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the branches option to the command line. + * + * @param null|string $pattern The pattern to filter branches with. + * + * @return LogCommandBuilder + */ + public function branches($pattern = null) + { + $this->processBuilder->add('--branches' . ($pattern ? '=' . $pattern : '')); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @param null|string $pattern The pattern to filter the tags with. + * + * @return LogCommandBuilder + */ + public function tags($pattern = null) + { + $this->processBuilder->add('--tags' . ($pattern ? '=' . $pattern : '')); + return $this; + } + + /** + * Add the remotes option to the command line. + * + * @param null|string $pattern The pattern to filter the remotes with. + * + * @return LogCommandBuilder + */ + public function remotes($pattern = null) + { + $this->processBuilder->add('--remotes' . ($pattern ? '=' . $pattern : '')); + return $this; + } + + /** + * Add the glob option to the command line. + * + * @param null|string $pattern The glob pattern. + * + * @return LogCommandBuilder + */ + public function glob($pattern = null) + { + $this->processBuilder->add('--glob=' . $pattern); + return $this; + } + + /** + * Add the exclude option to the command line. + * + * @param null|string $pattern The pattern to exclude. + * + * @return LogCommandBuilder + */ + public function exclude($pattern = null) + { + $this->processBuilder->add('--exclude=' . $pattern); + return $this; + } + + /** + * Add the ignore-missing option to the command line. + * + * @return LogCommandBuilder + */ + public function ignoreMissing() + { + $this->processBuilder->add('--ignore-missing'); + return $this; + } + + /** + * Add the bisect option to the command line. + * + * @return LogCommandBuilder + */ + public function bisect() + { + $this->processBuilder->add('--bisect'); + return $this; + } + + /** + * Add the cherry-mark option to the command line. + * + * @return LogCommandBuilder + */ + public function cherryMark() + { + $this->processBuilder->add('--cherry-mark'); + return $this; + } + + /** + * Add the cherry-pick option to the command line. + * + * @return LogCommandBuilder + */ + public function cherryPick() + { + $this->processBuilder->add('--cherry-pick'); + return $this; + } + + /** + * Add the left-only option to the command line. + * + * @return LogCommandBuilder + */ + public function leftOnly() + { + $this->processBuilder->add('--left-only'); + return $this; + } + + /** + * Add the right-only option to the command line. + * + * @return LogCommandBuilder + */ + public function rightOnly() + { + $this->processBuilder->add('--right-only'); + return $this; + } + + /** + * Add the cherry option to the command line. + * + * @return LogCommandBuilder + */ + public function cherry() + { + $this->processBuilder->add('--cherry'); + return $this; + } + + /** + * Add the walk-reflogs option to the command line. + * + * @return LogCommandBuilder + */ + public function walkReflogs() + { + $this->processBuilder->add('--walk-reflogs'); + return $this; + } + + /** + * Add the merge option to the command line. + * + * @return LogCommandBuilder + */ + public function merge() + { + $this->processBuilder->add('--merge'); + return $this; + } + + /** + * Add the boundary option to the command line. + * + * @return LogCommandBuilder + */ + public function boundary() + { + $this->processBuilder->add('--boundary'); + return $this; + } + + /** + * Add the simplify-by-decoration option to the command line. + * + * @return LogCommandBuilder + */ + public function simplifyByDecoration() + { + $this->processBuilder->add('--simplify-by-decoration'); + return $this; + } + + /** + * Add the full-history option to the command line. + * + * @return LogCommandBuilder + */ + public function fullHistory() + { + $this->processBuilder->add('--full-history'); + return $this; + } + + /** + * Add the dense option to the command line. + * + * @return LogCommandBuilder + */ + public function dense() + { + $this->processBuilder->add('--dense'); + return $this; + } + + /** + * Add the sparse option to the command line. + * + * @return LogCommandBuilder + */ + public function sparse() + { + $this->processBuilder->add('--sparse'); + return $this; + } + + /** + * Add the simplify-merges option to the command line. + * + * @return LogCommandBuilder + */ + public function simplifyMerges() + { + $this->processBuilder->add('--simplify-merges'); + return $this; + } + + /** + * Add the ancestry-path option to the command line. + * + * @return LogCommandBuilder + */ + public function ancestryPath() + { + $this->processBuilder->add('--ancestry-path'); + return $this; + } + + /** + * Add the date-order option to the command line. + * + * @return LogCommandBuilder + */ + public function dateOrder() + { + $this->processBuilder->add('--date-order'); + return $this; + } + + /** + * Add the author-date-order option to the command line. + * + * @return LogCommandBuilder + */ + public function authorDateOrder() + { + $this->processBuilder->add('--author-date-order'); + return $this; + } + + /** + * Add the topo-order option to the command line. + * + * @return LogCommandBuilder + */ + public function topoOrder() + { + $this->processBuilder->add('--topo-order'); + return $this; + } + + /** + * Add the reverse option to the command line. + * + * @return LogCommandBuilder + */ + public function reverse() + { + $this->processBuilder->add('--reverse'); + return $this; + } + + /** + * Add the objects option to the command line. + * + * @return LogCommandBuilder + */ + public function objects() + { + $this->processBuilder->add('--objects'); + return $this; + } + + /** + * Add the objects-edge option to the command line. + * + * @return LogCommandBuilder + */ + public function objectsEdge() + { + $this->processBuilder->add('--objects-edge'); + return $this; + } + + /** + * Add the unpacked option to the command line. + * + * @return LogCommandBuilder + */ + public function unpacked() + { + $this->processBuilder->add('--unpacked'); + return $this; + } + + /** + * Add the no-walk option to the command line. + * + * @param null|string $walk The value. + * + * @return LogCommandBuilder + */ + public function noWalk($walk = null) + { + $this->processBuilder->add('--no-walk' . ($walk ? '=' . $walk : '')); + return $this; + } + + /** + * Add the do-walk option to the command line. + * + * @return LogCommandBuilder + */ + public function doWalk() + { + $this->processBuilder->add('--do-walk'); + return $this; + } + + /** + * Add the pretty option to the command line. + * + * @param null|string $format The format. + * + * @return LogCommandBuilder + */ + public function pretty($format = null) + { + $this->processBuilder->add('--pretty' . ($format ? '=' . $format : '')); + return $this; + } + + /** + * Add the format option to the command line. + * + * @param string $format The format. + * + * @return LogCommandBuilder + */ + public function format($format) + { + $this->processBuilder->add('--format=' . $format); + return $this; + } + + /** + * Add the abbrev-commit option to the command line. + * + * @return LogCommandBuilder + */ + public function abbrevCommit() + { + $this->processBuilder->add('--abbrev-commit'); + return $this; + } + + /** + * Add the no-abbrev-commit option to the command line. + * + * @return LogCommandBuilder + */ + public function noAbbrevCommit() + { + $this->processBuilder->add('--no-abbrev-commit'); + return $this; + } + + /** + * Add the oneline option to the command line. + * + * @return LogCommandBuilder + */ + public function oneline() + { + $this->processBuilder->add('--oneline'); + return $this; + } + + /** + * Add the encoding option to the command line. + * + * @param string $encoding The encoding. + * + * @return LogCommandBuilder + */ + public function encoding($encoding) + { + $this->processBuilder->add('--encoding=' . $encoding); + return $this; + } + + /** + * Add the notes option to the command line. + * + * @param null|string $ref The ref name. + * + * @return LogCommandBuilder + */ + public function notes($ref = null) + { + $this->processBuilder->add('--notes' . ($ref ? '=' . $ref : '')); + return $this; + } + + /** + * Add the no-notes option to the command line. + * + * @return LogCommandBuilder + */ + public function noNotes() + { + $this->processBuilder->add('--no-notes'); + return $this; + } + + /** + * Add the show-notes option to the command line. + * + * @param null|string $ref The name of the ref. + * + * @return LogCommandBuilder + */ + public function showNotes($ref = null) + { + $this->processBuilder->add('--show-notes' . ($ref ? '=' . $ref : '')); + return $this; + } + + /** + * Add the show-signature option to the command line. + * + * @return LogCommandBuilder + */ + public function showSignature() + { + $this->processBuilder->add('--show-signature'); + return $this; + } + + /** + * Add the relative-date option to the command line. + * + * @return LogCommandBuilder + */ + public function relativeDate() + { + $this->processBuilder->add('--relative-date'); + return $this; + } + + /** + * Add the date option to the command line. + * + * @param string $format The date format. + * + * @return LogCommandBuilder + */ + public function date($format) + { + $this->processBuilder->add('--date=' . $format); + return $this; + } + + /** + * Add the parents option to the command line. + * + * @return LogCommandBuilder + */ + public function parents() + { + $this->processBuilder->add('--parents'); + return $this; + } + + /** + * Add the children option to the command line. + * + * @return LogCommandBuilder + */ + public function children() + { + $this->processBuilder->add('--children'); + return $this; + } + + /** + * Add the left-right option to the command line. + * + * @return LogCommandBuilder + */ + public function leftRight() + { + $this->processBuilder->add('--left-right'); + return $this; + } + + /** + * Add the graph option to the command line. + * + * @return LogCommandBuilder + */ + public function graph() + { + $this->processBuilder->add('--graph'); + return $this; + } + + /** + * Add the c option to the command line. + * + * @return LogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function c() + { + $this->processBuilder->add('-c'); + return $this; + } + + /** + * Add the cc option to the command line. + * + * @return LogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function cc() + { + $this->processBuilder->add('--cc'); + return $this; + } + + /** + * Add the m option to the command line. + * + * @return LogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function m() + { + $this->processBuilder->add('-m'); + return $this; + } + + /** + * Add the r option to the command line. + * + * @return LogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function r() + { + $this->processBuilder->add('-r'); + return $this; + } + + /** + * Add the t option to the command line. + * + * @return LogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function t() + { + $this->processBuilder->add('-t'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $pathspec Path spec to log. + * + * @param null|string $_ More optional pathspecs to log. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathspec = null, $_ = null) + { + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathspec) { + $this->processBuilder->add($pathspec); + } + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LsRemoteCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LsRemoteCommandBuilder.php new file mode 100644 index 00000000..3a1719cf --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/LsRemoteCommandBuilder.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Ls remote command builder. + */ +class LsRemoteCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('ls-remote'); + } + + /** + * Add the heads option to the command line. + * + * @return LsRemoteCommandBuilder + */ + public function heads() + { + $this->processBuilder->add('--heads'); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @return LsRemoteCommandBuilder + */ + public function tags() + { + $this->processBuilder->add('--tags'); + return $this; + } + + /** + * Add the upload-pack option to the command line. + * + * @param string $exec The value. + * + * @return LsRemoteCommandBuilder + */ + public function uploadPack($exec) + { + $this->processBuilder->add('--upload-pack')->add($exec); + return $this; + } + + /** + * Add the exit-code option to the command line. + * + * @return LsRemoteCommandBuilder + */ + public function exitCode() + { + $this->processBuilder->add('--exit-code'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param string $remote Name of the remote. + * + * @param null|string $refSpec Ref spec to list. + * + * @param null|string $_ More optional ref specs to log. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($remote, $refSpec = null, $_ = null) + { + $this->processBuilder->add($remote); + + $refSpec = func_get_args(); + array_shift($refSpec); + foreach ($refSpec as $ref) { + $this->processBuilder->add($ref); + } + + return $this->run(); + } + + /** + * Return a list of remote names. + * + * @param string $remote Name of the remote. + * + * @param null|string $refSpec Ref spec to list. + * + * @param null|string $_ More optional ref specs to log. + * + * @return array + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function getRefs($remote, $refSpec = null, $_ = null) + { + $output = call_user_func_array(array($this, 'execute'), func_get_args()); + $output = explode("\n", $output); + $output = array_map('trim', $output); + $output = array_filter($output); + + $refs = array(); + + foreach ($output as $line) { + $line = preg_split('~\s+~', $line); + + if ('^{}' != substr($line[1], -3)) { + $refs[$line[1]] = $line[0]; + } + } + + return $refs; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/MergeCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/MergeCommandBuilder.php new file mode 100644 index 00000000..c8a8f790 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/MergeCommandBuilder.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Aaron Rubin + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Merge command builder. + */ +class MergeCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('merge'); + } + + /** + * Add the quiet option to the command line. + * + * @return MergeCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the strategy option to the command line with the given strategy. + * + * @param string $strategy Strategy to use when merging. + * + * @return MergeCommandBuilder + */ + public function strategy($strategy) + { + $this->processBuilder->add('--strategy='.$strategy); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $branchOrTreeIsh Name of the branch or tree. + * + * @param null| $path Path to which check out. + * + * @param null|string $_ More optional arguments to append to the command. + * + * @return mixed + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($branchOrTreeIsh = null, $path = null, $_ = null) + { + if ($branchOrTreeIsh) { + $this->processBuilder->add($branchOrTreeIsh); + } + + $paths = func_get_args(); + array_shift($paths); + if (count($paths)) { + $this->processBuilder->add('--'); + foreach ($paths as $path) { + $this->processBuilder->add($path); + } + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PullCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PullCommandBuilder.php new file mode 100644 index 00000000..b6ff82c1 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PullCommandBuilder.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Ahmad Marzouq + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Pull command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class PullCommandBuilder extends AbstractCommandBuilder +{ + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('pull'); + } + + /** + * Add the quiet option to the command line. + * + * @return PullCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return PullCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the recurse-submodules option to the command line. + * + * @param string $recurse The value. + * + * @return PullCommandBuilder + */ + public function recurseSubmodules($recurse) + { + $this->processBuilder->add('--recurse-submodules=' . $recurse); + return $this; + } + + + /** + * Build the command and execute it. + * + * @param string $repository Name of the remote to pull from. + * + * @param null|string $refspec Ref spec to pull. + * + * @param null|string $_ More optional ref specs to pull. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($repository, $refspec = null, $_ = null) + { + $this->processBuilder->add($repository); + + $refspecs = func_get_args(); + array_shift($refspecs); + foreach ($refspecs as $refspec) { + $this->processBuilder->add($refspec); + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PushCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PushCommandBuilder.php new file mode 100644 index 00000000..ba66419d --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/PushCommandBuilder.php @@ -0,0 +1,313 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Push command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class PushCommandBuilder extends AbstractCommandBuilder +{ + const RECURSE_SUBMODULES_CHECK = 'check'; + + const RECURSE_SUBMODULES_ON_DEMAND = 'on-demand'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('push'); + } + + /** + * Add the all option to the command line. + * + * @return PushCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the prune option to the command line. + * + * @return PushCommandBuilder + */ + public function prune() + { + $this->processBuilder->add('--prune'); + return $this; + } + + /** + * Add the mirror option to the command line. + * + * @return PushCommandBuilder + */ + public function mirror() + { + $this->processBuilder->add('--mirror'); + return $this; + } + + /** + * Add the dry-run option to the command line. + * + * @return PushCommandBuilder + */ + public function dryRun() + { + $this->processBuilder->add('--dry-run'); + return $this; + } + + /** + * Add the porcelain option to the command line. + * + * @return PushCommandBuilder + */ + public function porcelain() + { + $this->processBuilder->add('--porcelain'); + return $this; + } + + /** + * Add the delete option to the command line. + * + * @return PushCommandBuilder + */ + public function delete() + { + $this->processBuilder->add('--delete'); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @return PushCommandBuilder + */ + public function tags() + { + $this->processBuilder->add('--tags'); + return $this; + } + + /** + * Add the follow-tags option to the command line. + * + * @return PushCommandBuilder + */ + public function followTags() + { + $this->processBuilder->add('--follow-tags'); + return $this; + } + + /** + * Add the receive-pack option to the command line. + * + * @param string $gitReceivePack The value. + * + * @return PushCommandBuilder + */ + public function receivePack($gitReceivePack) + { + $this->processBuilder->add('--receive-pack=' . $gitReceivePack); + return $this; + } + + /** + * Add the option to the command line. + * + * @param null|string $refname The ref name. + * + * @param null $expect The expect value. + * + * @return PushCommandBuilder + */ + public function forceWithLease($refname, $expect = null) + { + $this->processBuilder->add( + '--force-with-lease' . ($refname ? ('=' . $refname . ($expect ? ':' . $expect : '')) : '') + ); + return $this; + } + + /** + * Add the no-force-with-lease option to the command line. + * + * @return PushCommandBuilder + */ + public function noForceWithLease() + { + $this->processBuilder->add('--no-force-with-lease'); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return PushCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the repo option to the command line. + * + * @param string $repository The repository name. + * + * @return PushCommandBuilder + */ + public function repo($repository) + { + $this->processBuilder->add('--repo=' . $repository); + return $this; + } + + /** + * Add the set-upstream option to the command line. + * + * @return PushCommandBuilder + */ + public function setUpstream() + { + $this->processBuilder->add('--set-upstream'); + return $this; + } + + /** + * Add the thin option to the command line. + * + * @return PushCommandBuilder + */ + public function thin() + { + $this->processBuilder->add('--thin'); + return $this; + } + + /** + * Add the no-thin option to the command line. + * + * @return PushCommandBuilder + */ + public function noThin() + { + $this->processBuilder->add('--no-thin'); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return PushCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the verbose option to the command line. + * + * @return PushCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the recurse-submodules option to the command line. + * + * @param string $recurse The value. + * + * @return PushCommandBuilder + */ + public function recurseSubmodules($recurse) + { + $this->processBuilder->add('--recurse-submodules=' . $recurse); + return $this; + } + + /** + * Add the verify option to the command line. + * + * @return PushCommandBuilder + */ + public function verify() + { + $this->processBuilder->add('--verify'); + return $this; + } + + /** + * Add the no-verify option to the command line. + * + * @return PushCommandBuilder + */ + public function noVerify() + { + $this->processBuilder->add('--no-verify'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param string $repository Name of the remote to push to. + * + * @param null|string $refspec Ref spec to push. + * + * @param null|string $_ More optional ref specs to push. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($repository, $refspec = null, $_ = null) + { + $this->processBuilder->add($repository); + + $refspecs = func_get_args(); + array_shift($refspecs); + foreach ($refspecs as $refspec) { + $this->processBuilder->add($refspec); + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RemoteCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RemoteCommandBuilder.php new file mode 100644 index 00000000..c29eaacc --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RemoteCommandBuilder.php @@ -0,0 +1,334 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Remote command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class RemoteCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('remote'); + } + + /** + * Add the option to the command line. + * + * @return RemoteCommandBuilder + */ + public function verbose() + { + $this->processBuilder->add('--verbose'); + return $this; + } + + /** + * Add the add option to the command line. + * + * @param string $name Name of the new remote to add. + * + * @param string $url URL to the new remote. + * + * @return RemoteCommandBuilder + */ + public function add($name, $url) + { + $this->processBuilder->add('add')->add($name)->add($url); + return $this; + } + + /** + * Add the rename option to the command line. + * + * @param string $new The new name. + * + * @param null|string $old The old name. + * + * @return RemoteCommandBuilder + */ + public function rename($new, $old = null) + { + $this->processBuilder->add('rename'); + if ($old) { + $this->processBuilder->add($old); + } + $this->processBuilder->add($new); + return $this; + } + + /** + * Add the remove option to the command line. + * + * @param string $name The name of the remote to remove. + * + * @return RemoteCommandBuilder + */ + public function remove($name) + { + $this->processBuilder->add('remove')->add($name); + return $this; + } + + /** + * Add the set-head option to the command line. + * + * @param string $name The name of the head. + * + * @param string $branch The name of the branch. + * + * @return RemoteCommandBuilder + */ + public function setHead($name, $branch) + { + $this->processBuilder->add('set-head')->add($name)->add($branch); + return $this; + } + + /** + * Add the set-head option to the command line. + * + * @param string $name The name of the head. + * + * @return RemoteCommandBuilder + */ + public function setHeadAuto($name) + { + $this->processBuilder->add('set-head')->add($name)->add('--auto'); + return $this; + } + + /** + * Add the set-head option to the command line. + * + * @param string $name The name of the head. + * + * @return RemoteCommandBuilder + */ + public function setHeadDelete($name) + { + $this->processBuilder->add('set-head')->add($name)->add('--delete'); + return $this; + } + + /** + * Add the set-branches option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $branch Name of the branch. + * + * @param bool $add Flag if the name should be added. + * + * @return RemoteCommandBuilder + */ + public function setBranches($name, $branch, $add = false) + { + $this->processBuilder->add('set-branches'); + if ($add) { + $this->processBuilder->add('--add'); + } + $this->processBuilder->add($name)->add($branch); + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @param null|string $oldUrl The old URL. + * + * @return RemoteCommandBuilder + */ + public function setUrl($name, $url, $oldUrl = null) + { + $this->processBuilder->add('set-url')->add($name)->add($url); + if ($oldUrl) { + $this->processBuilder->add($oldUrl); + } + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @param null|string $oldUrl The old URL. + * + * @return RemoteCommandBuilder + */ + public function setPushUrl($name, $url, $oldUrl = null) + { + $this->processBuilder->add('set-url')->add($name)->add('--push')->add($url); + if ($oldUrl) { + $this->processBuilder->add($oldUrl); + } + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @return RemoteCommandBuilder + */ + public function addUrl($name, $url) + { + $this->processBuilder->add('set-url')->add('--add')->add($name)->add($url); + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @return RemoteCommandBuilder + */ + public function addPushUrl($name, $url) + { + $this->processBuilder->add('set-url')->add('--add')->add('--push')->add($name)->add($url); + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @return RemoteCommandBuilder + */ + public function deleteUrl($name, $url) + { + $this->processBuilder->add('set-url')->add('--delete')->add($name)->add($url); + return $this; + } + + /** + * Add the set-url option to the command line. + * + * @param string $name Name of the remote. + * + * @param string $url The URL. + * + * @return RemoteCommandBuilder + */ + public function deletePushUrl($name, $url) + { + $this->processBuilder->add('set-url')->add('--delete')->add('--push')->add($name)->add($url); + return $this; + } + + /** + * Add the show option to the command line. + * + * @param string $name Name of the remote. + * + * @return RemoteCommandBuilder + */ + public function show($name) + { + $this->processBuilder->add('show')->add($name); + return $this; + } + + /** + * Add the prune option to the command line. + * + * @param string $name Name of the remote. + * + * @param bool $dryRun Flag if a dry run shall be done. + * + * @return RemoteCommandBuilder + */ + public function prune($name, $dryRun = false) + { + $this->processBuilder->add('prune'); + if ($dryRun) { + $this->processBuilder->add('--dry-run'); + } + $this->processBuilder->add($name); + return $this; + } + + /** + * Add the update option to the command line. + * + * @param string $groupOrRemote Name of the remote or a remote group. + * + * @param bool $prune Flag if the remote shall be pruned. + * + * @return RemoteCommandBuilder + */ + public function update($groupOrRemote, $prune = false) + { + $this->processBuilder->add('update'); + if ($prune) { + $this->processBuilder->add('--prune'); + } + $this->processBuilder->add($groupOrRemote); + return $this; + } + + /** + * Execute the command and return the output. + * + * @return string + */ + public function execute() + { + return $this->run(); + } + + /** + * Return a list of remote names. + * + * @return array + */ + public function getNames() + { + $remotes = $this->execute(); + $remotes = explode("\n", $remotes); + $remotes = array_map('trim', $remotes); + $remotes = array_filter($remotes); + + return $remotes; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ResetCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ResetCommandBuilder.php new file mode 100644 index 00000000..7ab62643 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ResetCommandBuilder.php @@ -0,0 +1,148 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Reset command builder. + */ +class ResetCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('reset'); + } + + /** + * Add the quiet option to the command line. + * + * @return ResetCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the patch option to the command line. + * + * @return ResetCommandBuilder + */ + public function patch() + { + $this->processBuilder->add('--patch'); + return $this; + } + + /** + * Add the soft option to the command line. + * + * @return ResetCommandBuilder + */ + public function soft() + { + $this->processBuilder->add('--soft'); + return $this; + } + + /** + * Add the mixed option to the command line. + * + * @return ResetCommandBuilder + */ + public function mixed() + { + $this->processBuilder->add('--mixed'); + return $this; + } + + /** + * Add the hard option to the command line. + * + * @return ResetCommandBuilder + */ + public function hard() + { + $this->processBuilder->add('--hard'); + return $this; + } + + /** + * Add the merge option to the command line. + * + * @return ResetCommandBuilder + */ + public function merge() + { + $this->processBuilder->add('--merge'); + return $this; + } + + /** + * Add the keep option to the command line. + * + * @return ResetCommandBuilder + */ + public function keep() + { + $this->processBuilder->add('--keep'); + return $this; + } + + /** + * Add the commit to the command line. + * + * @param string $commit A commit hash. + * + * @return ResetCommandBuilder + */ + public function commit($commit) + { + $this->processBuilder->add($commit); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $path Path to reset. + * + * @param null|string $_ More optional pathes to reset. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($path = null, $_ = null) + { + $this->processBuilder->add('--'); + foreach (func_get_args() as $path) { + $this->processBuilder->add($path); + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RevParseCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RevParseCommandBuilder.php new file mode 100644 index 00000000..58a0581d --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RevParseCommandBuilder.php @@ -0,0 +1,436 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @author Radek Crlik + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Rev-parse command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class RevParseCommandBuilder extends AbstractCommandBuilder +{ + const ABBREV_REF_STRICT = 'strict'; + + const ABBREV_REF_LOOSE = 'loose'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('rev-parse'); + } + + /** + * Add the parseopt option to the command line. + * + * @return RevParseCommandBuilder + */ + public function parseopt() + { + $this->processBuilder->add('--parseopt'); + return $this; + } + + /** + * Add the keep-dashdash option to the command line. + * + * @return RevParseCommandBuilder + */ + public function keepDashDash() + { + $this->processBuilder->add('--keep-dashdash'); + return $this; + } + + /** + * Add the stop-at-non-option option to the command line. + * + * @return RevParseCommandBuilder + */ + public function stopAtNonOption() + { + $this->processBuilder->add('--stop-at-non-option'); + return $this; + } + + /** + * Add the stuck-long option to the command line. + * + * @return RevParseCommandBuilder + */ + public function stuckLong() + { + $this->processBuilder->add('--stuck-long'); + return $this; + } + + /** + * Add the sq-quote option to the command line. + * + * @return RevParseCommandBuilder + */ + public function sqQuote() + { + $this->processBuilder->add('--sq-quote'); + return $this; + } + + /** + * Add the revs-only option to the command line. + * + * @return RevParseCommandBuilder + */ + public function revsOnly() + { + $this->processBuilder->add('--revs-only'); + return $this; + } + + /** + * Add the no-revs option to the command line. + * + * @return RevParseCommandBuilder + */ + public function noRevs() + { + $this->processBuilder->add('--no-revs'); + return $this; + } + + /** + * Add the flags option to the command line. + * + * @return RevParseCommandBuilder + */ + public function flags() + { + $this->processBuilder->add('--flags'); + return $this; + } + + /** + * Add the no-flags option to the command line. + * + * @return RevParseCommandBuilder + */ + public function noFlags() + { + $this->processBuilder->add('--no-flags'); + return $this; + } + + /** + * Add the default option to the command line. + * + * @param string $arg Name of the default rev. + * + * @return RevParseCommandBuilder + */ + public function defaultRev($arg) + { + $this->processBuilder->add('--default')->add($arg); + return $this; + } + + /** + * Add the prefix option to the command line. + * + * @param string $arg The prefix. + * + * @return RevParseCommandBuilder + */ + public function prefix($arg) + { + $this->processBuilder->add('--prefix')->add($arg); + return $this; + } + + /** + * Add the verify option to the command line. + * + * @return RevParseCommandBuilder + */ + public function verify() + { + $this->processBuilder->add('--verify'); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return RevParseCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Add the sq option to the command line. + * + * @return RevParseCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function sq() + { + $this->processBuilder->add('--sq'); + return $this; + } + + /** + * Add the not option to the command line. + * + * @return RevParseCommandBuilder + */ + public function not() + { + $this->processBuilder->add('--not'); + return $this; + } + + /** + * Add the abbref-ref option to the command line. + * + * @param null|string $abbrev The value. + * + * @return RevParseCommandBuilder + */ + public function abbrevRef($abbrev = null) + { + $this->processBuilder->add('--abbrev-ref' . ($abbrev ? '=' . $abbrev : '')); + return $this; + } + + /** + * Add the short option to the command line. + * + * @param null|int $number The amount. + * + * @return RevParseCommandBuilder + */ + public function short($number = null) + { + $this->processBuilder->add('--short' . ($number ? '=' . $number : '')); + return $this; + } + + /** + * Add the symbolic option to the command line. + * + * @return RevParseCommandBuilder + */ + public function symbolic() + { + $this->processBuilder->add('--symbolic'); + return $this; + } + + /** + * Add the symbolic-full-name option to the command line. + * + * @return RevParseCommandBuilder + */ + public function symbolicFullName() + { + $this->processBuilder->add('--symbolic-full-name'); + return $this; + } + + /** + * Add the all option to the command line. + * + * @return RevParseCommandBuilder + */ + public function all() + { + $this->processBuilder->add('--all'); + return $this; + } + + /** + * Add the branches option to the command line. + * + * @param string $pattern The pattern. + * + * @return RevParseCommandBuilder + */ + public function branches($pattern) + { + $this->processBuilder->add('--branches=' . $pattern); + return $this; + } + + /** + * Add the tags option to the command line. + * + * @param string $pattern The pattern. + * + * @return RevParseCommandBuilder + */ + public function tags($pattern) + { + $this->processBuilder->add('--tags=' . $pattern); + return $this; + } + + /** + * Add the remotes option to the command line. + * + * @param string $pattern The pattern. + * + * @return RevParseCommandBuilder + */ + public function remotes($pattern) + { + $this->processBuilder->add('--remotes=' . $pattern); + return $this; + } + + /** + * Add the glob option to the command line. + * + * @param string $pattern The pattern. + * + * @return RevParseCommandBuilder + */ + public function glob($pattern) + { + $this->processBuilder->add('--glob=' . $pattern); + return $this; + } + + /** + * Add the exclude option to the command line. + * + * @param string $pattern The pattern. + * + * @return RevParseCommandBuilder + */ + public function exclude($pattern) + { + $this->processBuilder->add('--exclude=' . $pattern); + return $this; + } + + /** + * Add the disambiguate option to the command line. + * + * @param string $prefix The prefix. + * + * @return RevParseCommandBuilder + */ + public function disambiguate($prefix) + { + $this->processBuilder->add('--disambiguate=' . $prefix); + return $this; + } + + /** + * Add the since option to the command line. + * + * @param \DateTime|string $date The date. + * + * @return RevParseCommandBuilder + */ + public function since($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--since=' . $date); + return $this; + } + + /** + * Add the after option to the command line. + * + * @param \DateTime|string $date The date. + * + * @return RevParseCommandBuilder + */ + public function after($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--after=' . $date); + return $this; + } + + /** + * Add the until option to the command line. + * + * @param \DateTime|string $date The date. + * + * @return RevParseCommandBuilder + */ + public function until($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--until=' . $date); + return $this; + } + + /** + * Add the before option to the command line. + * + * @param \DateTime|string $date The date. + * + * @return RevParseCommandBuilder + */ + public function before($date) + { + if ($date instanceof \DateTime) { + $date = $date->format('Y-m-d H:i:s'); + } + $this->processBuilder->add('--before=' . $date); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $arg Optional additional argument. + * + * @param null|string $_ More optional arguments. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($arg = null, $_ = null) + { + foreach (func_get_args() as $arg) { + $this->processBuilder->add($arg); + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RmCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RmCommandBuilder.php new file mode 100644 index 00000000..75470db2 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/RmCommandBuilder.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Rm command builder. + */ +class RmCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('rm'); + } + + /** + * Add the force option to the command line. + * + * @return RmCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the dry-run option to the command line. + * + * @return RmCommandBuilder + */ + public function dryRun() + { + $this->processBuilder->add('--dry-run'); + return $this; + } + + /** + * Add the recursive option to the command line. + * + * @return RmCommandBuilder + */ + public function recursive() + { + $this->processBuilder->add('-r'); + return $this; + } + + /** + * Add the cached option to the command line. + * + * @return RmCommandBuilder + */ + public function cached() + { + $this->processBuilder->add('--cached'); + return $this; + } + + /** + * Add the ignore-unmatch option to the command line. + * + * @return RmCommandBuilder + */ + public function ignoreUnmatch() + { + $this->processBuilder->add('--ignore-unmatch'); + return $this; + } + + /** + * Add the quiet option to the command line. + * + * @return RmCommandBuilder + */ + public function quiet() + { + $this->processBuilder->add('--quiet'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param null|string $pathspec Path spec. + * + * @param null|string $_ More optional path specs. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathspec = null, $_ = null) + { + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathspec) { + $this->processBuilder->add($pathspec); + } + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShortLogCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShortLogCommandBuilder.php new file mode 100644 index 00000000..e60dbbd9 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShortLogCommandBuilder.php @@ -0,0 +1,162 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author David Molineus + * @author Christian Schiffler + * @author Tristan Lins + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * ShortLog command builder. + */ +class ShortLogCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('shortlog'); + } + + /** + * Add the option to the command line. + * + * @return ShortLogCommandBuilder + */ + public function numbered() + { + $this->processBuilder->add('--numbered'); + + return $this; + } + + /** + * Add the option to the command line. + * + * @return ShortLogCommandBuilder + */ + public function summary() + { + $this->processBuilder->add('--summary'); + + return $this; + } + + /** + * Add the option to the command line. + * + * @return ShortLogCommandBuilder + */ + public function email() + { + $this->processBuilder->add('--email'); + + return $this; + } + + /** + * Add the option to the command line. + * + * @param string $format The format. + * + * @return ShortLogCommandBuilder + */ + public function format($format) + { + $this->processBuilder->add('--format=' . $format); + + return $this; + } + + /** + * Add the option to the command line. + * + * @param string $revisionRange The revision range. + * + * @return ShortLogCommandBuilder + */ + public function revisionRange($revisionRange) + { + $this->processBuilder->add($revisionRange); + + return $this; + } + + /** + * Linewrap the output by wrapping each line at width. + * + * The first line of each entry is indented by indent1 spaces, and the second and subsequent lines are indented by + * indent2 spaces. + * + * Width, indent1, and indent2 default to 76, 6 and 9 respectively. + * + * If width is 0 (zero) then indent the lines of the output without wrapping them. + * + * @param int $width The width or 0 to disable indenting. + * + * @param null|int $indent1 The amount of spaces the first line of each entry is indented by. + * + * @param null|int $indent2 The amount of spaces subsequent lines of each entry are indented by. + * + * @return ShortLogCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function w($width, $indent1 = null, $indent2 = null) + { + if ($indent1) { + $width .= ',' . $indent1; + + if ($indent2) { + $width .= ',' . $indent2; + } + } + + $this->processBuilder->add('-w' . $width); + + return $this; + } + + /** + * Execute the command and return the result. + * + * @param null|string $pathSpec Optional path spec. + * + * @param null|string $_ Optional list of more path specs. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathSpec = null, $_ = null) + { + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathSpec) { + $this->processBuilder->add($pathSpec); + } + } + + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShowCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShowCommandBuilder.php new file mode 100644 index 00000000..9df28415 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/ShowCommandBuilder.php @@ -0,0 +1,208 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Show command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class ShowCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('show'); + } + + /** + * Add the option to the command line. + * + * @param null|string $format The format. + * + * @return ShowCommandBuilder + */ + public function pretty($format = null) + { + $this->processBuilder->add('--pretty' . ($format ? '=' . $format : '')); + return $this; + } + + /** + * Add the format option to the command line. + * + * @param null|string $format The format. + * + * @return ShowCommandBuilder + */ + public function format($format) + { + $this->processBuilder->add('--format=' . $format); + return $this; + } + + /** + * Add the abbrev-commit option to the command line. + * + * @return ShowCommandBuilder + */ + public function abbrevCommit() + { + $this->processBuilder->add('--abbrev-commit'); + return $this; + } + + /** + * Add the no-abbrev-commit option to the command line. + * + * @return ShowCommandBuilder + */ + public function noAbbrevCommit() + { + $this->processBuilder->add('--no-abbrev-commit'); + return $this; + } + + /** + * Add the oneline option to the command line. + * + * @return ShowCommandBuilder + */ + public function oneline() + { + $this->processBuilder->add('--oneline'); + return $this; + } + + /** + * Add the encoding option to the command line. + * + * @param string $encoding The encoding. + * + * @return ShowCommandBuilder + */ + public function encoding($encoding) + { + $this->processBuilder->add('--encoding=' . $encoding); + return $this; + } + + /** + * Add the notes option to the command line. + * + * @param null|string $ref The ref name. + * + * @return ShowCommandBuilder + */ + public function notes($ref = null) + { + $this->processBuilder->add('--notes' . ($ref ? '=' . $ref : '')); + return $this; + } + + /** + * Add the no-notes option to the command line. + * + * @return ShowCommandBuilder + */ + public function noNotes() + { + $this->processBuilder->add('--no-notes'); + return $this; + } + + /** + * Add the show-notes option to the command line. + * + * @param null|string $ref The ref name. + * + * @return ShowCommandBuilder + */ + public function showNotes($ref = null) + { + $this->processBuilder->add('--show-notes' . ($ref ? '=' . $ref : '')); + return $this; + } + + /** + * Add the standard-notes option to the command line. + * + * @return ShowCommandBuilder + */ + public function standardNotes() + { + $this->processBuilder->add('--standard-notes'); + return $this; + } + + /** + * Add the no-standard-notes option to the command line. + * + * @return ShowCommandBuilder + */ + public function noStandardNotes() + { + $this->processBuilder->add('--no-standard-notes'); + return $this; + } + + /** + * Add the show-signature option to the command line. + * + * @return ShowCommandBuilder + */ + public function showSignature() + { + $this->processBuilder->add('--show-signature'); + return $this; + } + + /** + * Add the no-patch option to the command line. + * + * @return ShowCommandBuilder + */ + public function noPatch() + { + $this->processBuilder->add('--no-patch'); + return $this; + } + + /** + * Build the command and execute it. + * + * @param string $object Name of the object to show. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($object) + { + $this->processBuilder->add($object); + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StashCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StashCommandBuilder.php new file mode 100644 index 00000000..b2384fe3 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StashCommandBuilder.php @@ -0,0 +1,241 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Ahmad Marzouq + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Stash command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class StashCommandBuilder extends AbstractCommandBuilder +{ + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('stash'); + } + + /** + * Adds a message to StashCommandBuilder + * + * @param string $message The stash message. + * + * @return StashCommandBuilder + */ + public function message($message) + { + $this->processBuilder->add($message); + return $this; + } + + /** + * List stashes and return the results + * + * @param string $options Takes options applicable to the git log command. + * + * @return mixed + */ + public function listStash($options = null) + { + $this->processBuilder->add('list'); + if ($options) { + $this->processBuilder->add($options); + } + return parent::run(); + } + + /** + * Show the changes recorded in the stash as a diff + * between the stashed state and its original parent. + * When no $stash is given, shows the latest one. + * + * @param int|null $stash Takes the stash number. + * + * @return mixed + */ + public function show($stash = null) + { + $this->processBuilder->add('show'); + if ($stash) { + $this->processBuilder->add('stash@{' . $stash . '}'); + } + return parent::run(); + } + + /** + * Remove a single stashed state from the stash list. + * When no $stash is given, it removes the latest one. + * + * @param int|null $stash Takes the stash number. + * + * @return mixed + */ + public function drop($stash = null) + { + $this->processBuilder->add('show'); + if ($stash) { + $this->processBuilder->add('stash@{' . $stash . '}'); + } + return parent::run(); + } + + /** + * Remove a single stashed state from the stash list + * and apply it on top of the current working tree state. + * + * @param int|null $stash Takes the stash number. + * + * @return mixed + */ + public function pop($stash = null) + { + $this->processBuilder->add('pop'); + if ($stash) { + $this->processBuilder->add('stash@{' . $stash . '}'); + } + return parent::run(); + } + + /** + * Like pop, but do not remove the state from the stash list. + * Unlike pop, $stash may be any commit that looks like a commit + * created by stash save or stash create. + * + * @param int|null $stash Takes the stash number. + * + * @return mixed + */ + public function apply($stash = null) + { + $this->processBuilder->add('pop'); + if ($stash) { + $this->processBuilder->add('stash@{' . $stash . '}'); + } + return parent::run(); + } + + + /** + * Creates and checks out a new branch named $branchname starting from the commit at + * which the $stash was originally created, + * applies the changes recorded in $stash to the new working tree and index. + * + * @param string $branchname The branch name. + * + * @param int|null $stash Takes the stash number. + * + * @return mixed + */ + public function branch($branchname, $stash = null) + { + $this->processBuilder->add('branch'); + $this->processBuilder->add($branchname); + if ($stash) { + $this->processBuilder->add('stash@{' . $stash . '}'); + } + return parent::run(); + } + + + /** + * Remove all the stashed states. + * + * @return mixed + */ + public function clear() + { + $this->processBuilder->add('clear'); + return parent::run(); + } + + + /** + * Save your local modifications to a new stash, + * and run git reset --hard to revert them. + * The part is optional and gives + * the description along with the stashed state. + * + * @param string $message The stash message. + * + * @return mixed + */ + public function save($message = null) + { + $this->processBuilder->add('branch'); + if ($message) { + $this->processBuilder->add($message); + } + return parent::run(); + } + + /** + * Create a stash (which is a regular commit object) + * and return its object name, + * without storing it anywhere in the ref namespace. + * + * @param string $message The stash message. + * + * @return mixed + */ + public function create($message = null) + { + $this->processBuilder->add('create'); + if ($message) { + $this->processBuilder->add($message); + } + return parent::run(); + } + + /** + * Store a given stash created via git stash create + * (which is a dangling merge commit) in the stash ref, + * updating the stash reflog. + * + * @param string $message The stash message. + * + * @param null|string $commit The commit hash. + * + * @return mixed + */ + public function store($message = null, $commit = null) + { + $this->processBuilder->add('store'); + if ($message) { + $this->processBuilder->add('--message '.$message); + } + if ($commit) { + $this->processBuilder->add($commit); + } + return parent::run(); + } + /** + * Execute the command and return the result. + * to use with message function . + * + * @return mixed + */ + public function execute() + { + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StatusCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StatusCommandBuilder.php new file mode 100644 index 00000000..862058a1 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/StatusCommandBuilder.php @@ -0,0 +1,331 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Status command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class StatusCommandBuilder extends AbstractCommandBuilder +{ + const UNTRACKED_FILES_NO = 'no'; + + const UNTRACKED_FILES_NORMAL = 'normal'; + + const UNTRACKED_FILES_ALL = 'all'; + + const IGNORE_SUBMODULES_NONE = 'none'; + + const IGNORE_SUBMODULES_UNTRACKED = 'untracked'; + + const IGNORE_SUBMODULES_DIRTY = 'dirty'; + + const IGNORE_SUBMODULES_ALL = 'all'; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('status'); + } + + /** + * Add the short option to the command line. + * + * @return StatusCommandBuilder + */ + public function short() + { + $this->processBuilder->add('--short'); + return $this; + } + + /** + * Add the branch option to the command line. + * + * @return StatusCommandBuilder + */ + public function branch() + { + $this->processBuilder->add('--branch'); + return $this; + } + + /** + * Add the porcelain option to the command line. + * + * @return StatusCommandBuilder + */ + public function porcelain() + { + $this->processBuilder->add('--porcelain'); + return $this; + } + + /** + * Add the long option to the command line. + * + * @return StatusCommandBuilder + */ + public function long() + { + $this->processBuilder->add('--long'); + return $this; + } + + /** + * Add the untracked-files option to the command line. + * + * @param null|string $mode The mode. + * + * @return StatusCommandBuilder + */ + public function untrackedFiles($mode = null) + { + $this->processBuilder->add('--untracked-files' . ($mode ? '=' . $mode : '')); + return $this; + } + + /** + * Add the ignore-submodules option to the command line. + * + * @param null|string $when The value. + * + * @return StatusCommandBuilder + */ + public function ignoreSubmodules($when = null) + { + $this->processBuilder->add('--ignore-submodules' . ($when ? '=' . $when : '')); + return $this; + } + + /** + * Add the ignored option to the command line. + * + * @return StatusCommandBuilder + */ + public function ignored() + { + $this->processBuilder->add('--ignored'); + return $this; + } + + /** + * Add the z option to the command line. + * + * @return StatusCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function z() + { + $this->processBuilder->add('-z'); + return $this; + } + + /** + * Add the column option to the command line. + * + * @param null|string $options The column options. + * + * @return StatusCommandBuilder + */ + public function column($options = null) + { + $this->processBuilder->add('--column' . ($options ? '=' . $options : '')); + return $this; + } + + /** + * Add the option to the command line. + * + * @return StatusCommandBuilder + */ + public function noColumn() + { + $this->processBuilder->add('--no-column'); + return $this; + } + + /** + * Return the parsed index and work tree status. + * + * The result will be an associative array of all files and an status array in the following format: + * + * array( + * '<pathspec>' => array( + * 'index' => [false | "M" | "A" | "D" | "R" | "C" | "U" | "?" | "!"], + * 'worktree' => [false | "M" | "A" | "D" | "R" | "C" | "U" | "?" | "!"], + * ) + * ) + * + * + * @param string $pathspec A path spec. + * + * @param string $_ Optional list of additional path specs. + * + * @return array + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function getStatus($pathspec = null, $_ = null) + { + $this->porcelain(); + + $status = call_user_func_array(array($this, 'execute'), func_get_args()); + $status = explode("\n", $status); + + $files = array(); + + foreach ($status as $line) { + if (trim($line)) { + $index = trim(substr($line, 0, 1)); + $worktree = trim(substr($line, 1, 1)); + + if ($index && $worktree) { + $file = trim(substr($line, 2)); + $files[$file] = array( + 'index' => $index ?: false, + 'worktree' => $worktree ?: false, + ); + } + } + } + + return $files; + } + + /** + * Return the parsed index status. + * + * The result will be an associative array of all files and their modification status in the following format: + * + * array( + * '<pathspec>' => [false | "M" | "A" | "D" | "R" | "C" | "U" | "?" | "!"], + * ) + * + * + * @param string $pathspec A path spec. + * + * @param string $_ Optional list of additional path specs. + * + * @return array + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function getIndexStatus($pathspec = null, $_ = null) + { + $this->porcelain(); + + $status = call_user_func_array(array($this, 'execute'), func_get_args()); + $status = explode("\n", $status); + + $files = array(); + + foreach ($status as $line) { + if ($line = trim($line)) { + $index = substr($line, 0, 1); + + if ($index) { + $file = trim(substr($line, 2)); + $files[$file] = $index; + } + } + } + + return $files; + } + + /** + * Return the parsed work tree status. + * + * The result will be an associative array of all files and their modification status in the following format: + * + * array( + * '<pathspec>' => [false | "M" | "A" | "D" | "R" | "C" | "U" | "?" | "!"], + * ) + * + * + * @param string $pathspec A path spec. + * + * @param string $_ Optional list of additional path specs. + * + * @return array + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function getWorkTreeStatus($pathspec = null, $_ = null) + { + $this->porcelain(); + + $status = call_user_func_array(array($this, 'execute'), func_get_args()); + $status = explode("\n", $status); + + $files = array(); + + foreach ($status as $line) { + if ($line = trim($line)) { + $worktree = trim(substr($line, 1, 1)); + + if ($worktree) { + $file = trim(substr($line, 2)); + $files[$file] = $worktree; + } + } + } + + return $files; + } + + /** + * Build the command and execute it. + * + * @param null|string $pathspec A path spec. + * + * @param null|string $_ Optional list of additional path specs. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($pathspec = null, $_ = null) + { + $args = func_get_args(); + if (count($args)) { + $this->processBuilder->add('--'); + foreach ($args as $pathspec) { + $this->processBuilder->add($pathspec); + } + } + return parent::run(); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/Command/TagCommandBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/TagCommandBuilder.php new file mode 100644 index 00000000..030cea0c --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/Command/TagCommandBuilder.php @@ -0,0 +1,296 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git\Command; + +/** + * Tag command builder. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class TagCommandBuilder extends AbstractCommandBuilder +{ + const CLEANUP_VERBATIM = 'verbatim'; + + const CLEANUP_WHITESPACE = 'whitespace'; + + const CLEANUP_STRIP = 'strip'; + + /** + * Flag if signing shall be done. + * + * @var bool + */ + protected $signIsset = false; + + /** + * Flag determining if the local user has been set. + * + * @var bool + */ + protected $localUserIsset = false; + + /** + * {@inheritDoc} + */ + protected function initializeProcessBuilder() + { + $this->processBuilder->add('tag'); + } + + /** + * Add the annotate option to the command line. + * + * @return TagCommandBuilder + */ + public function annotate() + { + $this->processBuilder->add('--annotate'); + return $this; + } + + /** + * Add the sign option to the command line. + * + * @return TagCommandBuilder + */ + public function sign() + { + $this->signIsset = true; + $this->processBuilder->add('--sign'); + return $this; + } + + /** + * Add the local-user option to the command line. + * + * @param string $keyId The id of the local user key. + * + * @return TagCommandBuilder + */ + public function localUser($keyId) + { + $this->localUserIsset = true; + $this->processBuilder->add('--local-user=' . $keyId); + return $this; + } + + /** + * Add the force option to the command line. + * + * @return TagCommandBuilder + */ + public function force() + { + $this->processBuilder->add('--force'); + return $this; + } + + /** + * Add the delete option to the command line. + * + * @return TagCommandBuilder + */ + public function delete() + { + $this->processBuilder->add('--delete'); + return $this; + } + + /** + * Add the verify option to the command line. + * + * @return TagCommandBuilder + */ + public function verify() + { + $this->processBuilder->add('--verify'); + return $this; + } + + /** + * Add the n option to the command line. + * + * @param int $num The number. + * + * @return TagCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function n($num) + { + $this->processBuilder->add('-n' . $num); + return $this; + } + + /** + * Add the l option to the command line. + * + * @param string $pattern The pattern. + * + * @return TagCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function l($pattern) + { + $this->processBuilder->add('--list')->add($pattern); + return $this; + } + + /** + * Add the column option to the command line. + * + * @param null|string $options The column options. + * + * @return TagCommandBuilder + */ + public function column($options = null) + { + $this->processBuilder->add('--column' . ($options ? '=' . $options : '')); + return $this; + } + + /** + * Add the no-column option to the command line. + * + * @return TagCommandBuilder + */ + public function noColumn() + { + $this->processBuilder->add('--no-column'); + return $this; + } + + /** + * Add the contains option to the command line. + * + * @param string $commit The commit hash. + * + * @return TagCommandBuilder + */ + public function contains($commit) + { + $this->processBuilder->add('--contains')->add($commit); + return $this; + } + + /** + * Add the points-at option to the command line. + * + * @param string $object The object the tag points at. + * + * @return TagCommandBuilder + */ + public function pointsAt($object) + { + $this->processBuilder->add('--points-at')->add($object); + return $this; + } + + /** + * Add the message option to the command line. + * + * @param string $message The message. + * + * @return TagCommandBuilder + */ + public function message($message) + { + $this->processBuilder->add('--message=' . $message); + return $this; + } + + /** + * Add the file option to the command line. + * + * @param string $file The file. + * + * @return TagCommandBuilder + */ + public function file($file) + { + $this->processBuilder->add('--file=' . $file); + return $this; + } + + /** + * Add the cleanup option to the command line. + * + * @param string $mode The cleanup mode. + * + * @return TagCommandBuilder + */ + public function cleanup($mode) + { + $this->processBuilder->add('--cleanup=' . $mode); + return $this; + } + + /** + * Build the command and execute it. + * + * @param string $tagName Name of the tag. + * + * @param null|string $commit Commit hash to tag. + * + * @return string + * + * @SuppressWarnings(PHPMD.ShortVariableName) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CamelCaseParameterName) + */ + public function execute($tagName = null, $commit = null) + { + if (!$this->signIsset && $this->repository->getConfig()->isSignTagsEnabled()) { + $this->sign()->localUser($this->repository->getConfig()->getSignCommitUser()); + } else { + if ($this->signIsset && !$this->localUserIsset && $this->repository->getConfig()->isSignTagsEnabled()) { + $this->localUser($this->repository->getConfig()->getSignCommitUser()); + } + } + + if ($tagName) { + $this->processBuilder->add($tagName); + } + + if ($commit) { + $this->processBuilder->add($commit); + } + + return parent::run(); + } + + /** + * Retrieve the tag names. + * + * @return string[] + */ + public function getNames() + { + $tags = $this->execute(); + $tags = explode("\n", $tags); + $tags = array_map('trim', $tags); + $tags = array_filter($tags); + + return $tags; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/GitConfig.php b/upload/src/addons/TickTackk/DeveloperTools/Git/GitConfig.php new file mode 100644 index 00000000..5b343a7e --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/GitConfig.php @@ -0,0 +1,201 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git; + +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; + +/** + * Shareable configuration for git repositories. + */ +class GitConfig +{ + /** + * The path to the git executable. + * + * @var string + */ + protected $gitExecutablePath = 'git'; + + /** + * ID of the GPG certificate to sign commits. + * + * @var string|null + */ + protected $signCommitUser = null; + + /** + * ID of the GPG certificate to sign tags. + * + * @var string|null + */ + protected $signTagUser = null; + + /** + * Logger facility. + * + * @var LoggerInterface + */ + protected $logger; + + /** + * Create new git config. + */ + public function __construct() + { + $this->logger = new NullLogger(); + } + + /** + * Set the git executable path. + * + * @param string $gitExecutablePath Path to the git executable. + * + * @return GitConfig + */ + public function setGitExecutablePath($gitExecutablePath) + { + $this->gitExecutablePath = (string) $gitExecutablePath; + return $this; + } + + /** + * Return the git executable path. + * + * @return string + */ + public function getGitExecutablePath() + { + return $this->gitExecutablePath; + } + + /** + * Enable signing of commits. + * + * @param string $signUser The id of the GPG certificate. + * + * @return GitConfig + */ + public function enableSignCommits($signUser) + { + $this->signCommitUser = (string) $signUser; + return $this; + } + + /** + * Disable signing of commits. + * + * @return $this + */ + public function disableSignCommits() + { + $this->signCommitUser = null; + return $this; + } + + /** + * Determine if signing commits is enabled. + * + * @return boolean + */ + public function isSignCommitsEnabled() + { + return (bool) $this->signCommitUser; + } + + /** + * Get the id of the GPG certificate to sign commits with. + * + * @return string|null + */ + public function getSignCommitUser() + { + return $this->signCommitUser; + } + + /** + * Enable signing of tags. + * + * @param string $signUser The id of the GPG certificate. + * + * @return GitConfig + */ + public function enableSignTags($signUser) + { + $this->signTagUser = (string) $signUser; + return $this; + } + + /** + * Disable signing of tags. + * + * @return GitConfig + */ + public function disableSignTags() + { + $this->signTagUser = null; + return $this; + } + + /** + * Determine if signing tags is enabled. + * + * @return boolean + */ + public function isSignTagsEnabled() + { + return (bool) $this->signTagUser; + } + + /** + * Get the id of the GPG certificate to sign tags with. + * + * @return string|null + */ + public function getSignTagUser() + { + return $this->signTagUser; + } + + /** + * Set the logger facility. + * + * @param LoggerInterface $logger The logger to use. + * + * @return GitConfig + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + return $this; + } + + /** + * Return the logger facility. + * + * @return LoggerInterface + */ + public function getLogger() + { + return $this->logger; + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/GitException.php b/upload/src/addons/TickTackk/DeveloperTools/Git/GitException.php new file mode 100644 index 00000000..0c467c71 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/GitException.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git; + +use Symfony\Component\Process\Process; + +/** + * Exception thrown when execution of git failed. + */ +class GitException extends \RuntimeException +{ + /** + * The working directory path. + * + * @var string + */ + protected $workingDirectory; + + /** + * The executed command line. + * + * @var string + */ + protected $commandLine; + + /** + * The git commands standard output. + * + * @var string + */ + protected $commandOutput; + + /** + * The git commands error output. + * + * @var string + */ + protected $errorOutput; + + /** + * Create a new git exception. + * + * @param string $message The error message. + * + * @param string $workingDirectory The working directory. + * + * @param string $commandLine The used command line. + * + * @param string $commandOutput The command output. + * + * @param string $errorOutput The command error output. + */ + public function __construct($message, $workingDirectory, $commandLine, $commandOutput, $errorOutput) + { + parent::__construct($message, 0, null); + $this->workingDirectory = (string) $workingDirectory; + $this->commandLine = (string) $commandLine; + $this->commandOutput = (string) $commandOutput; + $this->errorOutput = (string) $errorOutput; + } + + /** + * Return the working directory git was executed in. + * + * @return string + */ + public function getWorkingDirectory() + { + return $this->workingDirectory; + } + + /** + * Return the command line to execute git. + * + * @return string + */ + public function getCommandLine() + { + return $this->commandLine; + } + + /** + * Return the git commands standard output. + * + * @return string + */ + public function getCommandOutput() + { + return $this->commandOutput; + } + + /** + * Return the git commands error output. + * + * @return string + */ + public function getErrorOutput() + { + return $this->errorOutput; + } + + /** + * Create new exception from process. + * + * @param string $message The message to use. + * + * @param Process $process The process to create the message from. + * + * @return static + */ + public static function createFromProcess($message, Process $process) + { + return new static( + sprintf('%s [%s]', $message, $process->getCommandLine()) . + PHP_EOL . sprintf('work dir: %s', $process->getWorkingDirectory()) . + PHP_EOL . $process->getErrorOutput(), + $process->getWorkingDirectory(), + $process->getCommandLine(), + $process->getOutput(), + $process->getErrorOutput() + ); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/GitRepository.php b/upload/src/addons/TickTackk/DeveloperTools/Git/GitRepository.php new file mode 100644 index 00000000..484ee55a --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/GitRepository.php @@ -0,0 +1,347 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * This project is provided in good faith and hope to be usable by anyone. + * + * @package bit3/git-php + * @author Tristan Lins + * @author Christian Schiffler + * @author David Molineus + * @author Aaron Rubin + * @author Matthew Gamble + * @author Ahmad Marzouq + * @copyright 2014 Tristan Lins + * @license https://github.com/bit3/git-php/blob/master/LICENSE MIT + * @link https://github.com/bit3/git-php + * @filesource + */ + +namespace TickTackk\DeveloperTools\Git; + +use TickTackk\DeveloperTools\Git\Command\AddCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\BranchCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\CheckoutCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\ConfigCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\MergeCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\CloneCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\CommitCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\DescribeCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\FetchCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\InitCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\LogCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\LsRemoteCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\PushCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\RemoteCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\ResetCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\RevParseCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\RmCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\ShortLogCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\ShowCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\StatusCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\TagCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\PullCommandBuilder; +use TickTackk\DeveloperTools\Git\Command\StashCommandBuilder; + +/** + * GIT repository adapter. + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class GitRepository +{ + /** + * The path to the git repository. + * + * @var string + */ + public $repositoryPath; + + /** + * The shared git configuration. + * + * @var GitConfig + */ + public $config; + + /** + * Create a new git repository. + * + * @param string $repositoryPath The path to the git repository. + * + * @param GitConfig $config The configuration to use. + */ + public function __construct($repositoryPath, GitConfig $config = null) + { + $this->repositoryPath = (string) $repositoryPath; + $this->config = $config ?: new GitConfig(); + } + + /** + * Return the path to the git repository. + * + * @return string + */ + public function getRepositoryPath() + { + return $this->repositoryPath; + } + + /** + * Return the shared git config. + * + * @return GitConfig + */ + public function getConfig() + { + return $this->config; + } + + /** + * Determine if git is already initialized in the repository path. + * + * @return bool + */ + public function isInitialized() + { + return is_dir($this->repositoryPath . DIRECTORY_SEPARATOR . '.git'); + } + + /** + * Create an init command. + * + * @return InitCommandBuilder + */ + public function init() + { + return new InitCommandBuilder($this); + } + + /** + * Create a clone command. + * + * @return CloneCommandBuilder + */ + public function cloneRepository() + { + return new CloneCommandBuilder($this); + } + + /** + * Create a config command. + * + * @return ConfigCommandBuilder + */ + public function config() + { + return new ConfigCommandBuilder($this); + } + + /** + * Create a remote command. + * + * @return RemoteCommandBuilder + */ + public function remote() + { + return new RemoteCommandBuilder($this); + } + + /** + * Create a branch command. + * + * @return BranchCommandBuilder + */ + public function branch() + { + return new BranchCommandBuilder($this); + } + + /** + * Create a rev-parse command. + * + * @return RevParseCommandBuilder + */ + public function revParse() + { + return new RevParseCommandBuilder($this); + } + + /** + * Create describe command. + * + * @return DescribeCommandBuilder + */ + public function describe() + { + return new DescribeCommandBuilder($this); + } + + /** + * Create reset command. + * + * @return ResetCommandBuilder + */ + public function reset() + { + return new ResetCommandBuilder($this); + } + + /** + * Create checkout command. + * + * @return CheckoutCommandBuilder + */ + public function checkout() + { + return new CheckoutCommandBuilder($this); + } + + /** + * Create push command. + * + * @return PushCommandBuilder + */ + public function push() + { + return new PushCommandBuilder($this); + } + + /** + * Create fetch command. + * + * @return FetchCommandBuilder + */ + public function fetch() + { + return new FetchCommandBuilder($this); + } + + /** + * Create status command. + * + * @return StatusCommandBuilder + */ + public function status() + { + return new StatusCommandBuilder($this); + } + + /** + * Create add command. + * + * @return AddCommandBuilder + */ + public function add() + { + return new AddCommandBuilder($this); + } + + /** + * Create rm command. + * + * @return RmCommandBuilder + * + * @SuppressWarnings(PHPMD.ShortMethodName) + */ + public function rm() + { + return new RmCommandBuilder($this); + } + + /** + * Create commit command. + * + * @return CommitCommandBuilder + */ + public function commit() + { + return new CommitCommandBuilder($this); + } + + /** + * Create tag command. + * + * @return TagCommandBuilder + */ + public function tag() + { + return new TagCommandBuilder($this); + } + + /** + * Create show command. + * + * @return ShowCommandBuilder + */ + public function show() + { + return new ShowCommandBuilder($this); + } + + /** + * Create log command. + * + * @return LogCommandBuilder + */ + public function log() + { + return new LogCommandBuilder($this); + } + + /** + * Create shortlog command. + * + * @return ShortLogCommandBuilder + */ + public function shortlog() + { + return new ShortLogCommandBuilder($this); + } + + /** + * Create ls-remote command. + * + * @return LsRemoteCommandBuilder + */ + public function lsRemote() + { + return new LsRemoteCommandBuilder($this); + } + + /** + * Create Merge command. + * + * @return MergeCommandBuilder + */ + public function merge() + { + return new MergeCommandBuilder($this); + } + + /** + * Create Pull command. + * + * @return PullCommandBuilder + */ + public function pull() + { + return new PullCommandBuilder($this); + } + + /** + * Create stash command. + * + * @return StashCommandBuilder + */ + public function stash() + { + return new StashCommandBuilder($this); + } +} diff --git a/upload/src/addons/TickTackk/DeveloperTools/Git/LICENSE b/upload/src/addons/TickTackk/DeveloperTools/Git/LICENSE new file mode 100644 index 00000000..923d41c8 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Git/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Tristan Lins + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/LICENSE b/upload/src/addons/TickTackk/DeveloperTools/LICENSE new file mode 100644 index 00000000..8cbdff9e --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2014-2018 TickTackk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/Listener.php b/upload/src/addons/TickTackk/DeveloperTools/Listener.php new file mode 100644 index 00000000..f8a0dec5 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Listener.php @@ -0,0 +1,15 @@ +columns['license'] = ['type' => Entity::STR, 'default' => '']; + $structure->columns['gitignore'] = ['type' => Entity::STR, 'default' => '']; + $structure->columns['readme_md'] = ['type' => Entity::STR, 'default' => '']; + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/Setup.php b/upload/src/addons/TickTackk/DeveloperTools/Setup.php new file mode 100644 index 00000000..8033b9f6 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/Setup.php @@ -0,0 +1,26 @@ +schemaManager()->alterTable('xf_user', function(Alter $table) + { + $table->addColumn('license', 'mediumtext')->setDefault(''); + $table->addColumn('gitignore', 'mediumtext')->setDefault(''); + $table->addColumn('readme_md', 'mediumtext')->setDefault(''); + }); + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/XF/Admin/Controller/AddOn.php b/upload/src/addons/TickTackk/DeveloperTools/XF/Admin/Controller/AddOn.php new file mode 100644 index 00000000..64ef247b --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/XF/Admin/Controller/AddOn.php @@ -0,0 +1,38 @@ +assertAddOnAvailable($params->addon_id_url); + + $viewParams = [ + 'addOn' => $addOn + ]; + return $this->view('TickTackk\DeveloperTools\XF:AddOn\DeveloperOptions', 'developerTools_developer_options', $viewParams); + } + + public function actionSaveDeveloperOptions(ParameterBag $params) + { + $this->assertPostOnly(); + + $addOn = $this->assertAddOnAvailable($params->addon_id_url); + + $input = $this->filter([ + 'license' => 'str', + 'gitignore' => 'str', + 'readme_md' => 'str' + ]); + + $addOnId = $addOn->getAddOnId(); + $addOnEntity = $this->em()->findOne('XF:AddOn', ['addon_id' => $addOnId]); + $addOnEntity->bulkSet($input); + $addOnEntity->save(); + + return $this->redirect($this->buildLink('add-ons')); + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/XF/Service/AddOn/ReleaseBuilder.php b/upload/src/addons/TickTackk/DeveloperTools/XF/Service/AddOn/ReleaseBuilder.php new file mode 100644 index 00000000..9580ac63 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/XF/Service/AddOn/ReleaseBuilder.php @@ -0,0 +1,114 @@ +addOn; + $addOnDir = $addOn->getAddOnDirectory(); + + $ds = DIRECTORY_SEPARATOR; + + $repoDir = $addOnDir . $ds . '_repo'; + $uploadDir = $repoDir . $ds . 'upload'; + + if (is_dir($uploadDir)) + { + File::deleteDirectory($uploadDir); + } + File::createDirectory($repoDir, false); + + $this->repoRoot = $repoDir; + } + + protected function prepareFilesToCopy() + { + parent::prepareFilesToCopy(); + $this->prepareFilesToCopyForRepo(); + } + + protected function prepareFilesToCopyForRepo() + { + $addOnRoot = $this->addOnRoot; + $repoRoot = $this->repoRoot; + + $addOn = $this->addOn; + $ds = DIRECTORY_SEPARATOR; + $srcRoot = $repoRoot . $ds . 'upload' . $ds . 'src' . $ds . 'addons' . $ds . $addOn->prepareAddOnIdForPath(); + + $filesIterator = $this->getFileIterator($addOnRoot); + foreach ($filesIterator AS $file) + { + $path = $this->standardizePath($addOnRoot, $file->getPathname()); + if ($this->isPartOfExcludedDirectoryForRepo($path)) + { + continue; + } + + if (!$file->isDir()) + { + File::copyFile($file->getPathname(), $srcRoot . $ds . $path, false); + } + } + + $addOnId = $this->addOn->getAddOnId(); + $addOn = $this->em()->findOne('XF:AddOn', ['addon_id' => $addOnId]); + + if (!empty($addOn->license)) + { + $licenseContent = <<< LICENSE +{$addOn->license} +LICENSE; + File::writeFile($srcRoot . $ds . 'LICENSE', $licenseContent, false); + } + + if (!empty($addOn->gitignore)) + { + $gitIgnoreContent = <<< GITIGNORE +{$addOn->gitignore} +GITIGNORE; + File::writeFile($srcRoot . $ds . '.gitignore', $gitIgnoreContent, false); + } + + if (!empty($addOn->readme_md)) + { + $readMeMarkdownContent = <<< README_MD +{$addOn->readme_md} +README_MD; + File::writeFile($repoRoot . $ds . 'README.md', $readMeMarkdownContent, false); + } + + $git = new GitRepository($repoRoot); + $git->init()->execute(); + } + + protected function isPartOfExcludedDirectoryForRepo($path) + { + foreach ($this->getExcludedDirectoriesForRepo() AS $dir) + { + if (strpos($path, $dir) === 0) + { + return true; + } + } + return false; + } + + protected function getExcludedDirectoriesForRepo() + { + return [ + '_build', + '_releases', + '_repo' + ]; + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/admin_navigation/_metadata.json b/upload/src/addons/TickTackk/DeveloperTools/_output/admin_navigation/_metadata.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/admin_navigation/_metadata.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Admin-Controller-AddOn_TickTackk-DeveloperTools-XF-Admin-Controller-AddOn.json b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Admin-Controller-AddOn_TickTackk-DeveloperTools-XF-Admin-Controller-AddOn.json new file mode 100644 index 00000000..02177868 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Admin-Controller-AddOn_TickTackk-DeveloperTools-XF-Admin-Controller-AddOn.json @@ -0,0 +1,6 @@ +{ + "from_class": "XF\\Admin\\Controller\\AddOn", + "to_class": "TickTackk\\DeveloperTools\\XF\\Admin\\Controller\\AddOn", + "execute_order": 10, + "active": true +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Service-AddOn-ReleaseBuilder_TickTackk-DeveloperTools-XF-Service-AddOn-ReleaseBuilder.json b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Service-AddOn-ReleaseBuilder_TickTackk-DeveloperTools-XF-Service-AddOn-ReleaseBuilder.json new file mode 100644 index 00000000..b8437ec7 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/XF-Service-AddOn-ReleaseBuilder_TickTackk-DeveloperTools-XF-Service-AddOn-ReleaseBuilder.json @@ -0,0 +1,6 @@ +{ + "from_class": "XF\\Service\\AddOn\\ReleaseBuilder", + "to_class": "TickTackk\\DeveloperTools\\XF\\Service\\AddOn\\ReleaseBuilder", + "execute_order": 10, + "active": true +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/_metadata.json b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/_metadata.json new file mode 100644 index 00000000..84f86140 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/class_extensions/_metadata.json @@ -0,0 +1,8 @@ +{ + "XF-Admin-Controller-AddOn_TickTackk-DeveloperTools-XF-Admin-Controller-AddOn.json": { + "hash": "5ab46a6d8f0be87b47825c3124023cb8" + }, + "XF-Service-AddOn-ReleaseBuilder_TickTackk-DeveloperTools-XF-Service-AddOn-ReleaseBuilder.json": { + "hash": "dd1a7196ee5f82a13ee1c6168c3d1b8f" + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/_metadata.json b/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/_metadata.json new file mode 100644 index 00000000..47f73cf1 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/_metadata.json @@ -0,0 +1,5 @@ +{ + "entity_structure_4843cd9e4ef0b69dac8df6ac3e9b4baf.json": { + "hash": "ae0fa37ec75f741ef9a8f111fca7b342" + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/entity_structure_4843cd9e4ef0b69dac8df6ac3e9b4baf.json b/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/entity_structure_4843cd9e4ef0b69dac8df6ac3e9b4baf.json new file mode 100644 index 00000000..91d2461c --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/code_event_listeners/entity_structure_4843cd9e4ef0b69dac8df6ac3e9b4baf.json @@ -0,0 +1,9 @@ +{ + "event_id": "entity_structure", + "execute_order": 10, + "callback_class": "TickTackk\\DeveloperTools\\Listener", + "callback_method": "XFEntityAddOn_entity_structure", + "active": true, + "hint": "XF\\Entity\\AddOn", + "description": "Extends XF\\Entity\\AddOn to include 'license' and 'gitignore' columns in structure" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/extension_hint.php b/upload/src/addons/TickTackk/DeveloperTools/_output/extension_hint.php new file mode 100644 index 00000000..bfdbcaad --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/extension_hint.php @@ -0,0 +1,14 @@ +", + "replace": "{{ phrase('developerTools_developer_options') }}\n\t\t\t\t$0" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_option_group_list.json b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_option_group_list.json new file mode 100644 index 00000000..01ffcfec --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_option_group_list.json @@ -0,0 +1,9 @@ +{ + "template": "option_group_list", + "description": "Add the display order next to option group.", + "execution_order": 10, + "enabled": true, + "action": "str_replace", + "find": "label=\"{$group.title}\"", + "replace": "label=\"{$group.title} {$group.display_order}\"" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list.json b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list.json new file mode 100644 index 00000000..739ba5e4 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list.json @@ -0,0 +1,9 @@ +{ + "template": "permission_definition_list", + "description": "Add the display order next to permission definition interface group", + "execution_order": 10, + "enabled": true, + "action": "str_replace", + "find": "hint=\"{$permission.permission_group_id} / {$permission.permission_id}\"", + "replace": "hint=\"{$permission.display_order} - {$permission.permission_group_id} / {$permission.permission_id}\"" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list_interfa.json b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list_interfa.json new file mode 100644 index 00000000..140e2e94 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_definition_list_interfa.json @@ -0,0 +1,9 @@ +{ + "template": "permission_definition_list", + "description": "Add the display order next to permission definition interface group", + "execution_order": 10, + "enabled": true, + "action": "str_replace", + "find": "{$interfaceGroup.title}", + "replace": "$0\n{$interfaceGroup.display_order}" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros.json b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros.json new file mode 100644 index 00000000..60af93dc --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros.json @@ -0,0 +1,9 @@ +{ + "template": "permission_macros", + "description": "Add the display order next to permission", + "execution_order": 10, + "enabled": true, + "action": "str_replace", + "find": "label=\"{$permission.title}\"", + "replace": "label=\"{$permission.title} {$permission.display_order}\"" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros_interface_group.json b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros_interface_group.json new file mode 100644 index 00000000..6f760fa7 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/template_modifications/admin/developerTools_permission_macros_interface_group.json @@ -0,0 +1,9 @@ +{ + "template": "permission_macros", + "description": "Add the display order next to permission interface group", + "execution_order": 10, + "enabled": true, + "action": "str_replace", + "find": "{$interfaceGroup.title}", + "replace": "{$interfaceGroup.title} {$interfaceGroup.display_order}" +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/templates/_metadata.json b/upload/src/addons/TickTackk/DeveloperTools/_output/templates/_metadata.json new file mode 100644 index 00000000..aaa5ae38 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/templates/_metadata.json @@ -0,0 +1,7 @@ +{ + "admin/developerTools_developer_options.html": { + "version_id": 1000010, + "version_string": "1.0.0 Alpha", + "hash": "cd6b83a06f60b1f991445e39aeed44ce" + } +} \ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/_output/templates/admin/developerTools_developer_options.html b/upload/src/addons/TickTackk/DeveloperTools/_output/templates/admin/developerTools_developer_options.html new file mode 100644 index 00000000..dc68a2d2 --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/_output/templates/admin/developerTools_developer_options.html @@ -0,0 +1,18 @@ +{{ phrase('developerTools_developer_options_for_x_add_on', {'addon_title': $addOn.title}) }} + + +
+ +
+ + + + + + +
+
+ + +
+
\ No newline at end of file diff --git a/upload/src/addons/TickTackk/DeveloperTools/addon.json b/upload/src/addons/TickTackk/DeveloperTools/addon.json new file mode 100644 index 00000000..289a539e --- /dev/null +++ b/upload/src/addons/TickTackk/DeveloperTools/addon.json @@ -0,0 +1,14 @@ +{ + "legacy_addon_id": "", + "title": "Developer Tools", + "description": "", + "version_id": 1000010, + "version_string": "1.0.0 Alpha", + "dev": "TickTackk", + "dev_url": "https://twitter.com/t1cktackk", + "faq_url": "", + "support_url": "", + "extra_urls": [], + "require": [], + "icon": "fa-terminal" +} \ No newline at end of file