aboutsummaryrefslogtreecommitdiffstats
path: root/library/kzykhys/git/src/PHPGit/Command/CatCommand.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/CatCommand.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/CatCommand.php')
-rw-r--r--library/kzykhys/git/src/PHPGit/Command/CatCommand.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/library/kzykhys/git/src/PHPGit/Command/CatCommand.php b/library/kzykhys/git/src/PHPGit/Command/CatCommand.php
new file mode 100644
index 000000000..0c4fc1f41
--- /dev/null
+++ b/library/kzykhys/git/src/PHPGit/Command/CatCommand.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace PHPGit\Command;
+
+use PHPGit\Command;
+use PHPGit\Exception\GitException;
+
+/**
+ * Provide content or type and size information for repository objects - `git cat-file`
+ *
+ * @author Kazuyuki Hayashi <hayashi@valnur.net>
+ */
+class CatCommand extends Command
+{
+
+ /**
+ * Returns the contents of blob object
+ *
+ * ``` php
+ * $git = new PHPGit\Git();
+ * $git->setRepository('/path/to/repo');
+ * $contents = $git->cat->blob('e69de29bb2d1d6434b8b29ae775ad8');
+ * ```
+ *
+ * @param string $object The name of the blob object to show
+ *
+ * @throws GitException
+ * @return string
+ */
+ public function blob($object)
+ {
+ $process = $this->git->getProcessBuilder()
+ ->add('cat-file')
+ ->add('blob')
+ ->add($object)
+ ->getProcess();
+
+ return $this->git->run($process);
+ }
+
+ /**
+ * Returns the object type identified by **$object**
+ *
+ * ``` php
+ * $git = new PHPGit\Git();
+ * $git->setRepository('/path/to/repo');
+ * $type = $git->cat->type('e69de29bb2d1d6434b8b29ae775ad8');
+ * ```
+ *
+ * @param string $object The name of the object to show
+ *
+ * @throws GitException
+ * @return string
+ */
+ public function type($object)
+ {
+ $process = $this->git->getProcessBuilder()
+ ->add('cat-file')
+ ->add('-t')
+ ->add($object)
+ ->getProcess();
+
+ return trim($this->git->run($process));
+ }
+
+ /**
+ * Returns the object size identified by **$object**
+ *
+ * ``` php
+ * $git = new PHPGit\Git();
+ * $git->setRepository('/path/to/repo');
+ * $type = $git->cat->size('e69de29bb2d1d6434b8b29ae775ad8');
+ * ```
+ *
+ * @param string $object The name of the object to show
+ *
+ * @throws GitException
+ * @return string
+ */
+ public function size($object)
+ {
+ $process = $this->git->getProcessBuilder()
+ ->add('cat-file')
+ ->add('-s')
+ ->add($object)
+ ->getProcess();
+
+ return trim($this->git->run($process));
+ }
+
+} \ No newline at end of file