Пример #1
0
    fputs(STDOUT, "Registers git commits and their branches in the database\n\n--show-progress         Display the progress indicator\n--reset-startpoints     Re-start from the first commit in the repository\n--help                  Display this help\n\n");
    exit(0);
}
fputs(STDOUT, "*****************************************\n");
fputs(STDOUT, date('Y-m-d H:i', time()));
fputs(STDOUT, " GIT-COMMITS JOB STARTED\n");
$repo = new PHPGit_Repository($CFG->dataroot . '/local_dev/repos/moodle.git');
$config = get_config('local_dev');
if ($options['reset-startpoints'] or empty($config->gitstartpoints)) {
    set_config('gitstartpoints', json_encode(array()), 'local_dev');
    $config = get_config('local_dev');
}
$repo->git('remote update');
$gitbranches = array();
$recentstable = 0;
foreach ($repo->getBranches() as $gitbranch) {
    if ($gitbranch === 'master') {
        $gitbranches[] = $gitbranch;
        continue;
    }
    if (preg_match('~^MOODLE_([0-9]+)_STABLE$~', $gitbranch, $matches)) {
        $gitbranches[] = $gitbranch;
        if ($matches[1] > $recentstable) {
            $recentstable = $matches[1];
        }
        continue;
    }
}
if ($recentstable < 22) {
    throw new coding_exception('Something is wrong with the tracked repository, MOODLE_22_STABLE branch not found');
}