forked from danieljames/boost-tasks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-super-project
executable file
·56 lines (48 loc) · 1.84 KB
/
update-super-project
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
#!/usr/bin/env php
<?php
require_once(__DIR__.'/vendor/autoload.php');
use GetOptionKit\OptionCollection;
use BoostTasks\Db;
use BoostTasks\Settings;
use BoostTasks\CommandLineOptions;
use BoostTasks\GitHubEvents;
use BoostTasks\SuperProject;
function main($args) {
$specs = new OptionCollection;
$specs->add('no-fetch', "Don't fetch events from GitHub")
->defaultValue(false);
$specs->add('all', "Check for updates in all submodules, not just recently updated.")
->defaultValue(false);
$options = CommandLineOptions::process($args,
'Update the submodules in the super project',
$specs);
if (is_numeric($options)) { exit($options); }
Settings::init($options);
if ($options['cron']) {
// Quick and dirty check if the configuration has changed since last run.
$db = Settings::database();
$settings = \Nette\Neon\Neon::encode(Settings::safeSettings(), \Nette\Neon\Neon::BLOCK);
$record = $db->findOne('variable', 'name = "settings"');
if (!$record || $settings !== $record->value) {
echo "Configuration updated:\n\n{$settings}";
if ($record) { echo "\n\nOld configuration:\n\n{$record->value}"; }
if (!$record) {
$record = $db->dispense('variable');
$record->name = 'settings';
}
$record->value = $settings;
$record->updated_on = new DateTime();
$record->store();
$history = $db->dispense('history');
$history->name = $record->name;
$history->value = $record->value;
$history->updated_on = $record->updated_on;
$history->store();
}
}
if (!$options['no-fetch']) {
GitHubEvents::downloadEvents();
}
SuperProject::updateBranches(null, $options['all']);
}
main($_SERVER['argv']);