aboutsummaryrefslogtreecommitdiffstats
path: root/library/kzykhys/git/src/PHPGit/Command/ShowCommand.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 12:12:20 +1000
committerredmatrix <git@macgirvin.com>2016-05-10 12:12:20 +1000
commitb7e7ef0bf3ad47729ef45282a92a78f0dc0e3ec4 (patch)
tree2e4f069d66885c5ca5b77154e9dd5a43ec004ff5 /library/kzykhys/git/src/PHPGit/Command/ShowCommand.php
parentea1173f8f632151d02c71fe6004c6a64d014e80a (diff)
parent0b8a7f1bd03edb2bb18eb050fcb0b482d0e231be (diff)
downloadvolse-hubzilla-b7e7ef0bf3ad47729ef45282a92a78f0dc0e3ec4.tar.gz
volse-hubzilla-b7e7ef0bf3ad47729ef45282a92a78f0dc0e3ec4.tar.bz2
volse-hubzilla-b7e7ef0bf3ad47729ef45282a92a78f0dc0e3ec4.zip
Merge pull request #372 from anaqreon/plugin-repo
Manage addon git repositories via the admin plugins page
Diffstat (limited to 'library/kzykhys/git/src/PHPGit/Command/ShowCommand.php')
-rw-r--r--library/kzykhys/git/src/PHPGit/Command/ShowCommand.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/library/kzykhys/git/src/PHPGit/Command/ShowCommand.php b/library/kzykhys/git/src/PHPGit/Command/ShowCommand.php
new file mode 100644
index 000000000..866388357
--- /dev/null
+++ b/library/kzykhys/git/src/PHPGit/Command/ShowCommand.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace PHPGit\Command;
+
+use PHPGit\Command;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
+
+/**
+ * Show various types of objects - `git show`
+ *
+ * @author Kazuyuki Hayashi
+ */
+class ShowCommand extends Command
+{
+
+ /**
+ * Shows one or more objects (blobs, trees, tags and commits)
+ *
+ * ``` php
+ * $git = new PHPGit\Git();
+ * $git->setRepository('/path/to/repo');
+ * echo $git->show('3ddee587e209661c8265d5bfd0df999836f6dfa2');
+ * ```
+ *
+ * ##### Options
+ *
+ * - **format** (_string_) Pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, email, raw and format:<string>
+ * - **abbrev-commit** (_boolean_) Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix
+ *
+ * @param string $object The names of objects to show
+ * @param array $options [optional] An array of options {@see ShowCommand::setDefaultOptions}
+ *
+ * @return string
+ */
+ public function __invoke($object, array $options = array())
+ {
+ $options = $this->resolve($options);
+ $builder = $this->git->getProcessBuilder()
+ ->add('show');
+
+ $this->addFlags($builder, $options, array('abbrev-commit'));
+
+ if ($options['format']) {
+ $builder->add('--format=' . $options['format']);
+ }
+
+ $builder->add($object);
+
+ return $this->git->run($builder->getProcess());
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * - **format** (_string_) Pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, email, raw and format:<string>
+ * - **abbrev-commit** (_boolean_) Instead of showing the full 40-byte hexadecimal commit object name, show only a partial prefix
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'format' => null,
+ 'abbrev-commit' => false
+ ));
+
+ $resolver->setAllowedTypes(array(
+ 'format' => array('null', 'string'),
+ ));
+ }
+
+} \ No newline at end of file