aboutsummaryrefslogtreecommitdiffstats
path: root/library/kzykhys/git/src/PHPGit/Command/MvCommand.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-01 22:29:51 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-01 22:29:51 -0400
commitc2d15e6c3bd8a29bae89d184a999ddac15fcb807 (patch)
tree96cbbfa98f131d830fbfd154f82e37383bb37bd8 /library/kzykhys/git/src/PHPGit/Command/MvCommand.php
parentb1ae4d776c7c093c7f3ff6905e1a5302fbd5e3f6 (diff)
downloadvolse-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/MvCommand.php')
-rw-r--r--library/kzykhys/git/src/PHPGit/Command/MvCommand.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/library/kzykhys/git/src/PHPGit/Command/MvCommand.php b/library/kzykhys/git/src/PHPGit/Command/MvCommand.php
new file mode 100644
index 000000000..fe7ce6af6
--- /dev/null
+++ b/library/kzykhys/git/src/PHPGit/Command/MvCommand.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace PHPGit\Command;
+
+use PHPGit\Command;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
+
+/**
+ * Move or rename a file, a directory, or a symlink - `git mv`
+ *
+ * @author Kazuyuki Hayashi <hayashi@valnur.net>
+ */
+class MvCommand extends Command
+{
+
+ /**
+ * Move or rename a file, a directory, or a symlink
+ *
+ * ``` php
+ * $git = new PHPGit\Git();
+ * $git->setRepository('/path/to/repo');
+ * $git->mv('UPGRADE-1.0.md', 'UPGRADE-1.1.md');
+ * ```
+ *
+ * ##### Options
+ *
+ * - **force** (_boolean_) Force renaming or moving of a file even if the target exists
+ *
+ * @param string|array|\Iterator $source The files to move
+ * @param string $destination The destination
+ * @param array $options [optional] An array of options {@see MvCommand::setDefaultOptions}
+ *
+ * @return bool
+ */
+ public function __invoke($source, $destination, array $options = array())
+ {
+ $options = $this->resolve($options);
+ $builder = $this->git->getProcessBuilder()
+ ->add('mv');
+
+ $this->addFlags($builder, $options, array('force'));
+
+ if (!is_array($source) && !($source instanceof \Traversable)) {
+ $source = array($source);
+ }
+
+ foreach ($source as $value) {
+ $builder->add($value);
+ }
+
+ $builder->add($destination);
+
+ $this->git->run($builder->getProcess());
+
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * - **force** (_boolean_) Force renaming or moving of a file even if the target exists
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'force' => false
+ ));
+ }
+
+} \ No newline at end of file