1 | <?php |
||
12 | class DummyRepo |
||
13 | { |
||
14 | private $path; |
||
15 | |||
16 | private $gitDir; |
||
17 | |||
18 | public function __construct($name = null) |
||
19 | { |
||
20 | $name = empty($name) ? md5(mt_rand(0, 9999)) : $name; |
||
21 | $this->path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $name; |
||
22 | $this->gitDir = $this->path . DIRECTORY_SEPARATOR . '.git'; |
||
23 | } |
||
24 | |||
25 | public function setup() |
||
26 | { |
||
27 | mkdir($this->gitDir . DIRECTORY_SEPARATOR . 'hooks', 0777, true); |
||
28 | } |
||
29 | |||
30 | public function touchHook($name, $content = '# dummy hook') |
||
31 | { |
||
32 | file_put_contents($this->gitDir . DIRECTORY_SEPARATOR . 'hooks' . DIRECTORY_SEPARATOR . $name, $content); |
||
33 | } |
||
34 | |||
35 | public function merge() |
||
36 | { |
||
37 | file_put_contents($this->gitDir . DIRECTORY_SEPARATOR . 'MERGE_MSG', '# merge file'); |
||
38 | } |
||
39 | |||
40 | public function getPath() |
||
41 | { |
||
42 | return $this->path; |
||
43 | } |
||
44 | |||
45 | public function getGitDir() |
||
46 | { |
||
47 | return $this->path . DIRECTORY_SEPARATOR . '.git'; |
||
48 | } |
||
49 | |||
50 | public function cleanup() |
||
51 | { |
||
52 | system('rm -rf ' . $this->path); |
||
53 | } |
||
54 | } |
||
55 |