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/InitCommand.php | |
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/InitCommand.php')
-rw-r--r-- | library/kzykhys/git/src/PHPGit/Command/InitCommand.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/library/kzykhys/git/src/PHPGit/Command/InitCommand.php b/library/kzykhys/git/src/PHPGit/Command/InitCommand.php new file mode 100644 index 000000000..1ff56fa5b --- /dev/null +++ b/library/kzykhys/git/src/PHPGit/Command/InitCommand.php @@ -0,0 +1,65 @@ +<?php + +namespace PHPGit\Command; + +use PHPGit\Command; +use PHPGit\Exception\GitException; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * Create an empty git repository or reinitialize an existing one - `git init` + * + * @author Kazuyuki Hayashi <hayashi@valnur.net> + */ +class InitCommand extends Command +{ + + /** + * Create an empty git repository or reinitialize an existing one + * + * ``` php + * $git = new PHPGit\Git(); + * $git->init('/path/to/repo1'); + * $git->init('/path/to/repo2', array('shared' => true, 'bare' => true)); + * ``` + * + * ##### Options + * + * - **shared** (_boolean_) Specify that the git repository is to be shared amongst several users + * - **bare** (_boolean_) Create a bare repository + * + * @param string $path The directory to create an empty repository + * @param array $options [optional] An array of options {@see InitCommand::setDefaultOptions} + * + * @throws GitException + * @return bool + */ + public function __invoke($path, array $options = array()) + { + $options = $this->resolve($options); + $builder = $this->git->getProcessBuilder() + ->add('init'); + + $this->addFlags($builder, $options, array('shared', 'bare')); + + $process = $builder->add($path)->getProcess(); + $this->git->run($process); + + return true; + } + + /** + * {@inheritdoc} + * + * - **shared** (_boolean_) Specify that the git repository is to be shared amongst several users + * - **bare** (_boolean_) Create a bare repository + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'shared' => false, + 'bare' => false + )); + } + +}
\ No newline at end of file |