diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
commit | c2d15e6c3bd8a29bae89d184a999ddac15fcb807 (patch) | |
tree | 96cbbfa98f131d830fbfd154f82e37383bb37bd8 /library/kzykhys/git/src/PHPGit/Command/Remote | |
parent | b1ae4d776c7c093c7f3ff6905e1a5302fbd5e3f6 (diff) | |
download | volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.gz volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.bz2 volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.zip |
New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis
Diffstat (limited to 'library/kzykhys/git/src/PHPGit/Command/Remote')
3 files changed, 393 insertions, 0 deletions
diff --git a/library/kzykhys/git/src/PHPGit/Command/Remote/SetBranchesCommand.php b/library/kzykhys/git/src/PHPGit/Command/Remote/SetBranchesCommand.php new file mode 100644 index 000000000..4e17a4d48 --- /dev/null +++ b/library/kzykhys/git/src/PHPGit/Command/Remote/SetBranchesCommand.php @@ -0,0 +1,98 @@ +<?php + +namespace PHPGit\Command\Remote; + +use PHPGit\Command; + +/** + * Changes the list of branches tracked by the named remote + * + * @author Kazuyuki Hayashi + */ +class SetBranchesCommand extends Command +{ + + /** + * Alias of set() + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->branches('origin', array('master', 'develop')); + * ``` + * + * @param string $name The remote name + * @param array $branches The names of the tracked branch + * + * @return bool + */ + public function __invoke($name, array $branches) + { + return $this->set($name, $branches); + } + + /** + * Changes the list of branches tracked by the named remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->branches->set('origin', array('master', 'develop')); + * ``` + * + * @param string $name The remote name + * @param array $branches The names of the tracked branch + * + * @return bool + */ + public function set($name, array $branches) + { + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-branches') + ->add($name); + + foreach ($branches as $branch) { + $builder->add($branch); + } + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * Adds to the list of branches tracked by the named remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->branches->add('origin', array('master', 'develop')); + * ``` + * + * @param string $name The remote name + * @param array $branches The names of the tracked branch + * + * @return bool + */ + public function add($name, array $branches) + { + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-branches') + ->add($name) + ->add('--add'); + + foreach ($branches as $branch) { + $builder->add($branch); + } + + $this->git->run($builder->getProcess()); + + return true; + } + +}
\ No newline at end of file diff --git a/library/kzykhys/git/src/PHPGit/Command/Remote/SetHeadCommand.php b/library/kzykhys/git/src/PHPGit/Command/Remote/SetHeadCommand.php new file mode 100644 index 000000000..9241ef5b7 --- /dev/null +++ b/library/kzykhys/git/src/PHPGit/Command/Remote/SetHeadCommand.php @@ -0,0 +1,120 @@ +<?php + +namespace PHPGit\Command\Remote; + +use PHPGit\Command; + +/** + * Sets or deletes the default branch (i.e. the target of the symbolic-ref refs/remotes/<name>/HEAD) for the named remote + * + * @author Kazuyuki Hayashi + */ +class SetHeadCommand extends Command +{ + + /** + * Alias of set() + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->head('origin'); + * ``` + * + * @param string $name The remote name + * @param string $branch [optional] The symbolic-ref to set + * + * @return bool + */ + public function __invoke($name, $branch = null) + { + return $this->set($name, $branch); + } + + /** + * Sets the default branch for the named remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->head->set('origin'); + * ``` + * + * @param string $name The remote name + * @param string $branch [optional] The symbolic-ref to set + * + * @return bool + */ + public function set($name, $branch) + { + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-head') + ->add($name); + + if ($branch) { + $builder->add($branch); + } + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * Deletes the default branch for the named remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->head->delete('origin'); + * ``` + * + * @param string $name The remote name + * + * @return bool + */ + public function delete($name) + { + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-head') + ->add($name) + ->add('-d'); + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * Determine the default branch by querying remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->head->remote('origin'); + * ``` + * + * @param string $name The remote name + * + * @return bool + */ + public function remote($name) + { + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-head') + ->add($name) + ->add('-a'); + + $this->git->run($builder->getProcess()); + + return true; + } + +}
\ No newline at end of file diff --git a/library/kzykhys/git/src/PHPGit/Command/Remote/SetUrlCommand.php b/library/kzykhys/git/src/PHPGit/Command/Remote/SetUrlCommand.php new file mode 100644 index 000000000..7b7d84ff5 --- /dev/null +++ b/library/kzykhys/git/src/PHPGit/Command/Remote/SetUrlCommand.php @@ -0,0 +1,175 @@ +<?php + +namespace PHPGit\Command\Remote; + +use PHPGit\Command; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * Changes URL remote points to + * + * @author Kazuyuki Hayashi + */ +class SetUrlCommand extends Command +{ + + /** + * Alias of set() + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->url('origin', 'https://github.com/text/Text.git'); + * ``` + * + * ##### Options + * + * - **push** (_boolean_) Push URLs are manipulated instead of fetch URLs + * + * @param string $name The name of remote + * @param string $newUrl The new URL + * @param string $oldUrl [optional] The old URL + * @param array $options [optional] An array of options {@see SetUrlCommand::setDefaultOptions} + * + * @return bool + */ + public function __invoke($name, $newUrl, $oldUrl = null, array $options = array()) + { + return $this->set($name, $newUrl, $oldUrl, $options); + } + + /** + * Sets the URL remote to $newUrl + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->url->set('origin', 'https://github.com/text/Text.git'); + * ``` + * + * ##### Options + * + * - **push** (_boolean_) Push URLs are manipulated instead of fetch URLs + * + * @param string $name The name of remote + * @param string $newUrl The new URL + * @param string $oldUrl [optional] The old URL + * @param array $options [optional] An array of options {@see SetUrlCommand::setDefaultOptions} + * + * @return bool + */ + public function set($name, $newUrl, $oldUrl = null, array $options = array()) + { + $options = $this->resolve($options); + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-url'); + + $this->addFlags($builder, $options); + + $builder + ->add($name) + ->add($newUrl); + + if ($oldUrl) { + $builder->add($oldUrl); + } + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * Adds new URL to remote + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->url->add('origin', 'https://github.com/text/Text.git'); + * ``` + * + * ##### Options + * + * - **push** (_boolean_) Push URLs are manipulated instead of fetch URLs + * + * @param string $name The name of remote + * @param string $newUrl The new URL + * @param array $options [optional] An array of options {@see SetUrlCommand::setDefaultOptions} + * + * @return bool + */ + public function add($name, $newUrl, array $options = array()) + { + $options = $this->resolve($options); + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-url') + ->add('--add'); + + $this->addFlags($builder, $options); + + $builder + ->add($name) + ->add($newUrl); + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * Deletes all URLs matching regex $url + * + * ``` php + * $git = new PHPGit\Git(); + * $git->setRepository('/path/to/repo'); + * $git->remote->add('origin', 'https://github.com/kzykhys/Text.git'); + * $git->remote->url->delete('origin', 'https://github.com'); + * ``` + * + * ##### Options + * + * - **push** (_boolean_) Push URLs are manipulated instead of fetch URLs + * + * @param string $name The remote name + * @param string $url The URL to delete + * @param array $options [optional] An array of options {@see SetUrlCommand::setDefaultOptions} + * + * @return bool + */ + public function delete($name, $url, array $options = array()) + { + $options = $this->resolve($options); + $builder = $this->git->getProcessBuilder() + ->add('remote') + ->add('set-url') + ->add('--delete'); + + $this->addFlags($builder, $options); + + $builder + ->add($name) + ->add($url); + + $this->git->run($builder->getProcess()); + + return true; + } + + /** + * {@inheritdoc} + * + * - **push** (_boolean_) Push URLs are manipulated instead of fetch URLs + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'push' => false + )); + } + +}
\ No newline at end of file |