|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* main class running all the updates |
|
5
|
|
|
* |
|
6
|
|
|
* |
|
7
|
|
|
*/ |
|
8
|
|
|
class UpdateModules extends BuildTask |
|
|
|
|
|
|
9
|
|
|
{ |
|
10
|
|
|
protected $enabled = true; |
|
11
|
|
|
|
|
12
|
|
|
protected $title = "Update Modules"; |
|
13
|
|
|
|
|
14
|
|
|
protected $description = "Adds files necessary for publishing a module to GitHub. The list of modules is specified in standard config or else it retrieves a list of modules from GitHub."; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* e.g. |
|
18
|
|
|
* - moduleA |
|
19
|
|
|
* - moduleB |
|
20
|
|
|
* - moduleC |
|
21
|
|
|
* |
|
22
|
|
|
* |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
private static $modules_to_update = array(); |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* e.g. |
|
29
|
|
|
* - ClassNameForUpdatingFileA |
|
30
|
|
|
* - ClassNameForUpdatingFileB |
|
31
|
|
|
* |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
private static $files_to_update = array(); |
|
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* e.g. |
|
37
|
|
|
* - ClassNameForUpdatingFileA |
|
38
|
|
|
* - ClassNameForUpdatingFileB |
|
39
|
|
|
* |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
private static $commands_to_run = array(); |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
public static $unsolvedItems = array(); |
|
45
|
|
|
|
|
46
|
|
|
public function run($request) |
|
47
|
|
|
{ |
|
48
|
|
|
increase_time_limit_to(3600); |
|
49
|
|
|
|
|
50
|
|
|
//Check temp module folder is empty |
|
51
|
|
|
$tempFolder = GitHubModule::Config()->get('absolute_temp_folder'); |
|
52
|
|
|
$tempDirFiles = scandir($tempFolder); |
|
53
|
|
|
if (count($tempDirFiles) > 2) { |
|
54
|
|
|
die('<h2>' . $tempFolder . ' is not empty, please delete or move files </h2>'); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
//Get list of all modules from GitHub |
|
58
|
|
|
$gitUserName = $this->Config()->get('github_user_name'); |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
$modules = GitRepoFinder::get_all_repos(); |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
/* |
|
64
|
|
|
* Get files to add to modules |
|
65
|
|
|
* */ |
|
66
|
|
|
$files = ClassInfo::subclassesFor('AddFileToModule'); |
|
67
|
|
|
array_shift($files); |
|
68
|
|
|
$limitedFileClasses = $this->Config()->get('files_to_update'); |
|
69
|
|
|
if ($limitedFileClasses === 'none') { |
|
70
|
|
|
$files = []; |
|
71
|
|
|
} elseif (is_array($limitedFileClasses) && count($limitedFileClasses)) { |
|
72
|
|
|
$files = array_intersect($files, $limitedFileClasses); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/* |
|
76
|
|
|
* Get commands to run on modules |
|
77
|
|
|
* */ |
|
78
|
|
|
|
|
79
|
|
|
$commands = ClassInfo::subclassesFor('RunCommandLineMethodOnModule'); |
|
80
|
|
|
array_shift($commands); |
|
81
|
|
|
$limitedCommands = $this->Config()->get('commands_to_run'); |
|
82
|
|
|
if ($limitedCommands === 'none') { |
|
83
|
|
|
$commands = []; |
|
84
|
|
|
} elseif (is_array($limitedCommands) && count($limitedCommands)) { |
|
85
|
|
|
$commands = array_intersect($commands, $limitedCommands); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
set_error_handler('errorHandler', E_ALL); |
|
90
|
|
|
foreach ($modules as $count => $module) { |
|
|
|
|
|
|
91
|
|
|
$this->currentModule = $module; |
|
|
|
|
|
|
92
|
|
|
try { |
|
93
|
|
|
$this->processOneModule($module, $count, $files, $commands); |
|
94
|
|
|
} catch (Exception $e) { |
|
95
|
|
|
GeneralMethods::outputToScreen("<li> Could not complete processing $module: " . $e->getMessage() . " </li>"); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
restore_error_handler(); |
|
100
|
|
|
|
|
101
|
|
|
$this->writeLog(); |
|
102
|
|
|
//to do .. |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
protected function errorHandler(int $errno, string $errstr) |
|
|
|
|
|
|
106
|
|
|
{ |
|
107
|
|
|
GeneralMethods::outputToScreen("<li> Could not complete processing module: " . $errstr . " </li>"); |
|
108
|
|
|
|
|
109
|
|
|
UpdateModules::addUnsolvedProblem($this->currentModule, "Could not complete processing module: " . $errstr); |
|
110
|
|
|
|
|
111
|
|
|
return true; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
protected function processOneModule($module, $count, $files, $commands) |
|
115
|
|
|
{ |
|
116
|
|
|
if (stripos($module, 'silverstripe-') === false) { |
|
117
|
|
|
$module = "silverstripe-" . $module; |
|
118
|
|
|
} |
|
119
|
|
|
echo "<h2>" . ($count+1) . ". ".$module."</h2>"; |
|
120
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
$moduleObject = GitHubModule::get_or_create_github_module($module); |
|
123
|
|
|
|
|
124
|
|
|
$this->checkUpdateTag($moduleObject); |
|
125
|
|
|
|
|
126
|
|
|
$updateComposerJson = $this->Config()->get('update_composer_json'); |
|
127
|
|
|
|
|
128
|
|
|
// Check if all necessary files are perfect on GitHub repo already, |
|
129
|
|
|
// if so we can skip that module. But! ... if there are commands to run |
|
130
|
|
|
// over the files in the repo, then we need to clone the repo anyhow, |
|
131
|
|
|
// so skip the check |
|
132
|
|
|
if (count($commands) == 0 && ! $updateComposerJson) { |
|
133
|
|
|
$moduleFilesOK = true; |
|
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
foreach ($files as $file) { |
|
136
|
|
|
$fileObj = $file::create($moduleObject); |
|
137
|
|
|
$checkFileName = $fileObj->getFileLocation(); |
|
138
|
|
|
$GitHubFileText = $moduleObject -> getRawFileFromGithub($checkFileName); |
|
139
|
|
|
if ($GitHubFileText) { |
|
140
|
|
|
$fileCheck = $fileObj->compareWithText($GitHubFileText); |
|
141
|
|
|
if (! $fileCheck) { |
|
142
|
|
|
$moduleFilesOK = false; |
|
|
|
|
|
|
143
|
|
|
} |
|
144
|
|
|
} else { |
|
145
|
|
|
$moduleFilesOK = false; |
|
|
|
|
|
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$repository = $moduleObject->checkOrSetGitCommsWrapper($forceNew = true); |
|
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
|
|
153
|
|
|
$this->moveOldReadMe($moduleObject); |
|
154
|
|
|
|
|
155
|
|
|
|
|
156
|
|
|
$checkConfigYML = $this->Config()->get('check_config_yml'); |
|
157
|
|
|
if ($checkConfigYML) { |
|
158
|
|
|
$this->checkConfigYML($moduleObject); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
if ($updateComposerJson) { |
|
162
|
|
|
$composerJsonObj = new ComposerJson($moduleObject); |
|
163
|
|
|
$composerJsonObj->updateJsonFile(); |
|
164
|
|
|
$moduleObject->setDescription($composerJsonObj->getDescription()); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
$excludedWords = $this->Config()->get('excluded_words'); |
|
168
|
|
|
|
|
169
|
|
|
|
|
170
|
|
|
if (count($excludedWords) > 0) { |
|
171
|
|
|
$folder = GitHubModule::Config()->get('absolute_temp_folder') . '/' . $moduleObject->moduleName . '/'; |
|
172
|
|
|
|
|
173
|
|
|
$results = $this->checkDirExcludedWords($folder.'/'.$moduleObject->modulename, $excludedWords); |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
if ($results && count($results > 0)) { |
|
|
|
|
|
|
177
|
|
|
$msg = "<h4>The following excluded words were found: </h4><ul>"; |
|
178
|
|
|
foreach ($results as $file => $words) { |
|
179
|
|
|
foreach ($words as $word) { |
|
180
|
|
|
$msg .= "<li>$word in $file</li>"; |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
$msg .= '</ul>'; |
|
184
|
|
|
|
|
185
|
|
|
//trigger_error ("excluded words found in files(s)"); |
|
|
|
|
|
|
186
|
|
|
GeneralMethods::outputToScreen($msg); |
|
187
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
|
|
192
|
|
|
foreach ($files as $file) { |
|
193
|
|
|
//run file update |
|
194
|
|
|
|
|
195
|
|
|
$obj = $file::create($moduleObject); |
|
196
|
|
|
$obj->run(); |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
$moduleDir = $moduleObject->Directory(); |
|
200
|
|
|
|
|
201
|
|
|
foreach ($commands as $command) { |
|
202
|
|
|
//run file update |
|
203
|
|
|
|
|
204
|
|
|
|
|
205
|
|
|
$obj = $command::create($moduleDir); |
|
206
|
|
|
$obj->run(); |
|
207
|
|
|
|
|
208
|
|
|
|
|
209
|
|
|
//run command |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
//Update Repository description |
|
213
|
|
|
//$moduleObject->updateGitHubInfo(array()); |
|
|
|
|
|
|
214
|
|
|
|
|
215
|
|
View Code Duplication |
if (! $moduleObject->add()) { |
|
|
|
|
|
|
216
|
|
|
$msg = "Could not add files module to Repo"; |
|
217
|
|
|
GeneralMethods::outputToScreen($msg); |
|
218
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
219
|
|
|
return; |
|
220
|
|
|
} |
|
221
|
|
View Code Duplication |
if (! $moduleObject->commit()) { |
|
|
|
|
|
|
222
|
|
|
$msg = "Could not commit files to Repo"; |
|
223
|
|
|
GeneralMethods::outputToScreen($msg); |
|
224
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
225
|
|
|
return; |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
View Code Duplication |
if (! $moduleObject->push()) { |
|
|
|
|
|
|
229
|
|
|
$msg = "Could not push files to Repo"; |
|
230
|
|
|
GeneralMethods::outputToScreen($msg); |
|
231
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
232
|
|
|
return; |
|
233
|
|
|
} |
|
234
|
|
View Code Duplication |
if (! $moduleObject->removeClone()) { |
|
|
|
|
|
|
235
|
|
|
$msg = "Could not remove local copy of repo"; |
|
236
|
|
|
GeneralMethods::outputToScreen($msg); |
|
237
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
$addRepoToScrutinzer = $this->Config()->get('add_to_scrutinizer'); |
|
241
|
|
|
if ($addRepoToScrutinzer) { |
|
242
|
|
|
$moduleObject->addRepoToScrutinzer(); |
|
243
|
|
|
} |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
|
|
247
|
|
|
|
|
248
|
|
|
protected function renameTest($moduleObject) |
|
249
|
|
|
{ |
|
250
|
|
|
$oldName = $moduleObject->Directory() . "/tests/ModuleTest.php"; |
|
251
|
|
|
|
|
252
|
|
|
if (! file_exists($oldName)) { |
|
253
|
|
|
print_r($oldName); |
|
254
|
|
|
return false; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
|
|
259
|
|
|
$newName = $moduleObject->Directory() . "tests/" . $moduleObject->ModuleName . "Test.php"; |
|
260
|
|
|
|
|
261
|
|
|
GeneralMethods::outputToScreen("Renaming $oldName to $newName"); |
|
262
|
|
|
|
|
263
|
|
|
unlink($newName); |
|
264
|
|
|
|
|
265
|
|
|
rename($oldName, $newName); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
public static function addUnsolvedProblem($moduleName, $problemString) |
|
269
|
|
|
{ |
|
270
|
|
|
if (!isset(UpdateModules::$unsolvedItems[$moduleName])) { |
|
271
|
|
|
UpdateModules::$unsolvedItems[$moduleName] = array(); |
|
272
|
|
|
} |
|
273
|
|
|
array_push(UpdateModules::$unsolvedItems[$moduleName], $problemString); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
protected function writeLog() |
|
277
|
|
|
{ |
|
278
|
|
|
$debug = $this->Config()->get('debug'); |
|
|
|
|
|
|
279
|
|
|
|
|
280
|
|
|
$dateStr = date("Y/m/d H:i:s"); |
|
281
|
|
|
|
|
282
|
|
|
$html = '<h1> Modules checker report at ' .$dateStr . '</h1>'; |
|
283
|
|
|
|
|
284
|
|
|
if (count(UpdateModules::$unsolvedItems) == 0) { |
|
285
|
|
|
$html .= ' <h2> No unresolved problems in modules</h2>'; |
|
286
|
|
|
} else { |
|
287
|
|
|
$html .= ' |
|
288
|
|
|
<h2> Unresolved problems in modules</h2> |
|
289
|
|
|
|
|
290
|
|
|
<table border = 1> |
|
291
|
|
|
<tr><th>Module</th><th>Problem</th></tr>'; |
|
292
|
|
|
|
|
293
|
|
|
foreach (UpdateModules::$unsolvedItems as $moduleName => $problems) { |
|
294
|
|
|
if (is_array($problems)) { |
|
295
|
|
|
foreach ($problems as $problem) { |
|
296
|
|
|
$html .= '<tr><td>'.$moduleName.'</td><td>'. $problem .'</td></tr>'; |
|
297
|
|
|
} |
|
298
|
|
|
} elseif (is_string($problems)) { |
|
299
|
|
|
$html .= '<tr><td>'.$moduleName.'</td><td>'. $problems.'</td></tr>'; |
|
300
|
|
|
} |
|
301
|
|
|
} |
|
302
|
|
|
$html .= '</table>'; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
|
|
307
|
|
|
$logFolder = $this->Config()->get('logfolder'); |
|
308
|
|
|
|
|
309
|
|
|
$filename = $logFolder . date('U') . '.html'; |
|
310
|
|
|
|
|
311
|
|
|
GeneralMethods::outputToScreen("Writing to $filename"); |
|
312
|
|
|
|
|
313
|
|
|
$result = file_put_contents($filename, $html); |
|
314
|
|
|
|
|
315
|
|
|
if (! $result) { |
|
316
|
|
|
GeneralMethods::outputToScreen("Could not write log file"); |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
protected function checkConfigYML($module) |
|
321
|
|
|
{ |
|
322
|
|
|
$configYml = ConfigYML::create($module)->reWrite(); |
|
|
|
|
|
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
private function checkFile($module, $filename) |
|
326
|
|
|
{ |
|
327
|
|
|
$folder = GitHubModule::Config()->get('absolute_temp_folder'); |
|
328
|
|
|
return file_exists($folder.'/'.$module.'/'.$filename); |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
private function checkReadMe($module) |
|
332
|
|
|
{ |
|
333
|
|
|
return $this->checkFile($module, "README.MD"); |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
private function checkDirExcludedWords($directory, $wordArray) |
|
337
|
|
|
{ |
|
338
|
|
|
$filesAndFolders = scandir($directory); |
|
339
|
|
|
|
|
340
|
|
|
$problem_files = array(); |
|
341
|
|
|
foreach ($filesAndFolders as $fileOrFolder) { |
|
342
|
|
|
if ($fileOrFolder == '.' || $fileOrFolder == '..' || $fileOrFolder == '.git') { |
|
343
|
|
|
continue; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
$fileOrFolderFullPath = $directory . '/' . $fileOrFolder; |
|
347
|
|
|
if (is_dir($fileOrFolderFullPath)) { |
|
348
|
|
|
$dir = $fileOrFolderFullPath; |
|
349
|
|
|
$problem_files = array_merge($this->checkDirExcludedWords($dir, $wordArray), $problem_files); |
|
350
|
|
|
} |
|
351
|
|
|
if (is_file($fileOrFolderFullPath)) { |
|
352
|
|
|
$file = $fileOrFolderFullPath; |
|
353
|
|
|
$matchedWords = $this->checkFileExcludedWords($file, $wordArray); |
|
354
|
|
|
|
|
355
|
|
|
if ($matchedWords) { |
|
|
|
|
|
|
356
|
|
|
$problem_files[$file] = $matchedWords; |
|
357
|
|
|
} |
|
358
|
|
|
} |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
return $problem_files; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
private function checkFileExcludedWords($fileName, $wordArray) |
|
365
|
|
|
{ |
|
366
|
|
|
$matchedWords = array(); |
|
367
|
|
|
|
|
368
|
|
|
$fileName = str_replace('////', '/', $fileName); |
|
369
|
|
|
if (filesize($fileName) == 0) { |
|
370
|
|
|
return $matchedWords; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
|
|
374
|
|
|
$fileContent = file_get_contents($fileName); |
|
375
|
|
View Code Duplication |
if (!$fileContent) { |
|
|
|
|
|
|
376
|
|
|
$msg = "Could not open $fileName to check for excluded words"; |
|
377
|
|
|
|
|
378
|
|
|
GeneralMethods::outputToScreen($msg); |
|
379
|
|
|
UpdateModules::$unsolvedItems[$moduleObject->ModuleName] = $msg; |
|
|
|
|
|
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
foreach ($wordArray as $word) { |
|
383
|
|
|
$matches = array(); |
|
|
|
|
|
|
384
|
|
|
$matchCount = preg_match_all('/' . $word . '/i', $fileContent); |
|
385
|
|
|
|
|
386
|
|
|
|
|
387
|
|
|
|
|
388
|
|
|
|
|
389
|
|
|
|
|
390
|
|
|
if ($matchCount > 0) { |
|
391
|
|
|
array_push($matchedWords, $word); |
|
392
|
|
|
} |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
return $matchedWords; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
private function checkUpdateTag($moduleObject) |
|
399
|
|
|
{ |
|
400
|
|
|
$tagDelayString = $this->Config()->get('tag_delay'); |
|
401
|
|
|
$nextTag = null; |
|
|
|
|
|
|
402
|
|
|
|
|
403
|
|
|
if (!$tagDelayString) { |
|
404
|
|
|
$tagDelayString = "-3 weeks"; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
|
|
408
|
|
|
$tagDelay = strtotime($tagDelayString); |
|
409
|
|
|
if (!$tagDelay) { |
|
410
|
|
|
$tagDelay = strtotime("-3 weeks"); |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
$tag = $moduleObject->getLatestTag(); |
|
414
|
|
|
|
|
415
|
|
|
$commitTime = $moduleObject->getLatestCommitTime(); |
|
416
|
|
|
|
|
417
|
|
|
if (! $commitTime) { // if no commits, cannot create a tag |
|
418
|
|
|
return false; |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
$createTag = false; |
|
|
|
|
|
|
422
|
|
|
|
|
423
|
|
|
|
|
424
|
|
|
$newTagString = ''; |
|
425
|
|
|
|
|
426
|
|
|
if (! $tag) { |
|
427
|
|
|
$createTag = true; |
|
|
|
|
|
|
428
|
|
|
$newTagString = '1.0.0'; |
|
429
|
|
|
} elseif ($tag && $commitTime > $tag['timestamp'] && $commitTime < $tagDelay) { |
|
430
|
|
|
$changeType = $moduleObject->getChangeTypeSinceLastTag(); |
|
431
|
|
|
|
|
432
|
|
|
$newTagString = $this->findNextTag($tag, $changeType); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
if ($newTagString) { |
|
436
|
|
|
GeneralMethods::outputToScreen('<li> Creating new tag '.$newTagString.' ... </li>'); |
|
437
|
|
|
|
|
438
|
|
|
//git tag -a 0.0.1 -m "testing tag" |
|
439
|
|
|
$options = array( |
|
440
|
|
|
'a' => $newTagString, |
|
441
|
|
|
'm' => $this->Config()->get('tag_create_message') |
|
442
|
|
|
); |
|
443
|
|
|
|
|
444
|
|
|
$moduleObject->createTag($options); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
return true; |
|
448
|
|
|
} |
|
449
|
|
|
|
|
450
|
|
|
protected function findNextTag($tag, $changeType) |
|
451
|
|
|
{ |
|
452
|
|
|
switch ($changeType) { |
|
453
|
|
|
|
|
454
|
|
|
case 'MAJOR': |
|
455
|
|
|
$tag['tagparts'][0] = intval($tag['tagparts'][0]) + 1; |
|
456
|
|
|
$tag['tagparts'][1] = 0; |
|
457
|
|
|
$tag['tagparts'][2] = 0; |
|
458
|
|
|
break; |
|
459
|
|
|
|
|
460
|
|
|
case 'MINOR': |
|
|
|
|
|
|
461
|
|
|
|
|
462
|
|
|
$tag['tagparts'][1] = intval($tag['tagparts'][1]) + 1; |
|
463
|
|
|
$tag['tagparts'][2] = 0; |
|
464
|
|
|
break; |
|
465
|
|
|
|
|
466
|
|
|
default: |
|
467
|
|
|
case 'PATCH': |
|
|
|
|
|
|
468
|
|
|
$tag['tagparts'][2] = intval($tag['tagparts'][2]) + 1; |
|
469
|
|
|
break; |
|
470
|
|
|
} |
|
471
|
|
|
|
|
472
|
|
|
$newTagString = trim(implode('.', $tag['tagparts'])); |
|
473
|
|
|
return $newTagString; |
|
474
|
|
|
} |
|
475
|
|
|
|
|
476
|
|
|
protected function moveOldReadMe($moduleObject) |
|
477
|
|
|
{ |
|
478
|
|
|
$tempDir = GitHubModule::Config()->get('absolute_temp_folder'); |
|
479
|
|
|
$oldReadMe = $tempDir . '/' . $moduleObject->ModuleName . '/' .'README.md'; |
|
480
|
|
|
|
|
481
|
|
|
if (!file_exists($oldReadMe)) { |
|
482
|
|
|
return false; |
|
483
|
|
|
} |
|
484
|
|
|
|
|
485
|
|
|
|
|
486
|
|
|
$oldreadmeDestinationFiles = array( |
|
487
|
|
|
'docs/en/INDEX.md', |
|
488
|
|
|
'docs/en/README.old.md', |
|
489
|
|
|
); |
|
490
|
|
|
|
|
491
|
|
|
|
|
492
|
|
|
$copied = false; |
|
493
|
|
|
foreach ($oldreadmeDestinationFiles as $file) { |
|
494
|
|
|
$filePath = $tempDir . '/' . $moduleObject->ModuleName . '/' . $file; |
|
495
|
|
|
|
|
496
|
|
|
if (!file_exists($filePath)) { |
|
497
|
|
|
$copied = true; |
|
498
|
|
|
copy($oldReadMe, $filePath); |
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
if ($copied) { |
|
502
|
|
|
unlink($oldReadMe); |
|
503
|
|
|
} |
|
504
|
|
|
} |
|
505
|
|
|
} |
|
506
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.