mirror of
https://github.com/boostorg/boost-tasks.git
synced 2026-01-19 16:12:13 +00:00
57 lines
1.8 KiB
PHP
Executable File
57 lines
1.8 KiB
PHP
Executable File
#!/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']);
|