blob: 0c4fc1f41619f721292330db4fc62c7b38b8fdb0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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));
}
}
|