From c2d15e6c3bd8a29bae89d184a999ddac15fcb807 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 1 May 2016 22:29:51 -0400 Subject: New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis --- .../kzykhys/git/src/PHPGit/Command/CatCommand.php | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 library/kzykhys/git/src/PHPGit/Command/CatCommand.php (limited to 'library/kzykhys/git/src/PHPGit/Command/CatCommand.php') 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 @@ + + */ +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 -- cgit v1.2.3