1 | <?php |
||
12 | class GitProcessor |
||
13 | { |
||
14 | /** @var bool */ |
||
15 | private $force; |
||
16 | |||
17 | /** @var SymfonyStyle */ |
||
18 | private $io; |
||
19 | |||
20 | private $splitContentCursor = 0; |
||
21 | |||
22 | /** @var array */ |
||
23 | private $commitMessages; |
||
24 | |||
25 | /** @var array */ |
||
26 | private $splitContent = []; |
||
27 | |||
28 | /** @var string */ |
||
29 | private $outputFilename; |
||
30 | |||
31 | /** @var string */ |
||
32 | private $githubRepositoryUrl; |
||
33 | |||
34 | /** @var string */ |
||
35 | private $workspacePath; |
||
36 | |||
37 | /** |
||
38 | * GitHelper constructor. |
||
39 | * |
||
40 | * @param string $githubRepositoryUrl |
||
41 | * @param boolean $force |
||
42 | * @param string $inputFilePath |
||
43 | * @param string $outputFilename |
||
44 | * @param array $commitMessages |
||
45 | */ |
||
46 | public function __construct( |
||
47 | $githubRepositoryUrl, |
||
48 | $force, |
||
49 | $inputFilePath, |
||
50 | $outputFilename, |
||
51 | array $commitMessages |
||
52 | ) { |
||
53 | $this->githubRepositoryUrl = $githubRepositoryUrl; |
||
54 | $this->force = $force; |
||
55 | $this->outputFilename = $outputFilename; |
||
56 | $this->commitMessages = $commitMessages; |
||
57 | $splitContent = file_get_contents($inputFilePath); |
||
58 | $this->splitContent = explode(' ', $splitContent); |
||
59 | $workspacePath = sys_get_temp_dir() . '/gitaski' . rand(0, 1000000); |
||
60 | $this->workspacePath = $workspacePath; |
||
61 | mkdir($this->workspacePath); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return void |
||
66 | */ |
||
67 | public function initLocalRepository() |
||
71 | |||
72 | /** |
||
73 | * @param DateTime $date |
||
74 | */ |
||
75 | public function addCommit(DateTime $date) |
||
98 | |||
99 | public function clean() |
||
103 | |||
104 | /** |
||
105 | * @param DateTime $date |
||
106 | * |
||
107 | * @return DateTime |
||
108 | */ |
||
109 | public function getPreviousSunday(DateTime $date) |
||
113 | |||
114 | /** |
||
115 | * @param SymfonyStyle $io |
||
116 | */ |
||
117 | public function setIo(SymfonyStyle $io) |
||
121 | |||
122 | /** |
||
123 | * @return void |
||
124 | */ |
||
125 | private function forcePush() |
||
129 | |||
130 | /** |
||
131 | * @param array $symbol |
||
132 | * @param DateTime $lastSunday |
||
133 | * |
||
134 | * @throws Exception |
||
135 | */ |
||
136 | public function writeSymbol($symbol, DateTime $lastSunday) |
||
154 | |||
155 | /** |
||
156 | * @param array $symbol |
||
157 | * @param DateTime $lastSunday |
||
158 | * |
||
159 | * @return array |
||
160 | * @throws Exception |
||
161 | */ |
||
162 | private function getDatesFromSymbol($symbol, DateTime $lastSunday) |
||
186 | |||
187 | /** |
||
188 | * @param DateTime $date |
||
189 | * @param integer $days |
||
190 | * |
||
191 | * @return DateTime |
||
192 | */ |
||
193 | private function sub(DateTime $date, $days) |
||
199 | |||
200 | /** |
||
201 | * @param DateTime $date |
||
202 | * @param integer $days |
||
203 | * |
||
204 | * @return DateTime |
||
205 | */ |
||
206 | private function add(DateTime $date, $days) |
||
212 | |||
213 | /** |
||
214 | * @param string $cmd |
||
215 | * @param bool $ignoreErrors |
||
216 | * |
||
217 | * @throws Exception |
||
218 | */ |
||
219 | private function execCmd($cmd, $ignoreErrors = false) |
||
247 | } |