1: <?php
2: namespace Contrib\Component\System\Git;
3:
4: use Contrib\Component\System\SystemCommand;
5:
6: /**
7: * Git command.
8: *
9: * @author Kitamura Satoshi <with.no.parachute@gmail.com>
10: */
11: class GitCommand extends SystemCommand
12: {
13: /**
14: * Command name or path.
15: *
16: * @var string
17: */
18: protected $commandPath = 'git';
19:
20: // API
21:
22: /**
23: * Return branch names.
24: *
25: * @return array
26: */
27: public function getBranches()
28: {
29: $command = $this->createCommand('branch');
30:
31: return $this->executeCommand($command);
32: }
33:
34: /**
35: * Return HEAD commit.
36: *
37: * @return array
38: */
39: public function getHeadCommit()
40: {
41: $command = $this->createCommand("log -1 --pretty=format:'%H\n%aN\n%ae\n%cN\n%ce\n%s'");
42:
43: return $this->executeCommand($command);
44: }
45:
46: /**
47: * Return remote repositories.
48: *
49: * @return array
50: */
51: public function getRemotes()
52: {
53: $command = $this->createCommand('remote -v');
54:
55: return $this->executeCommand($command);
56: }
57: }
58: