Пример #1
0
 function testFork()
 {
     $Git = new Git($this->__repos[1]);
     $this->assertTrue($Git->create());
     $File = new File(TMP . 'tests/git/working/test/master/.gitignore');
     $this->assertTrue($File->write('this is something new'));
     $Git->commit('Updating git ignore');
     $Git->push();
     $File = new File(TMP . 'tests/git/working/test/master/new_file.txt', true, 0777);
     $this->assertTrue($File->write('this is something new'));
     $Git->commit('Adding new file');
     $Git->push();
     $Git->logResponse = true;
     $result = $Git->fork("gwoo");
     $this->assertTrue(file_exists(TMP . 'tests/git/repo/forks/gwoo/test.git'));
     $this->assertTrue(file_exists(TMP . 'tests/git/working/forks/gwoo/test/master/'));
     $result = $Git->find('all');
     $this->assertEqual($result[0]['Repo']['message'], 'Adding new file');
     $this->assertEqual($result[1]['Repo']['message'], 'Updating git ignore');
     $Git->config($this->__repos[1]);
     $Git->branch = null;
     $result = $Git->fork("bob");
     $this->assertTrue(file_exists(TMP . 'tests/git/repo/forks/bob/test.git'));
     $this->assertTrue(file_exists(TMP . 'tests/git/working/forks/bob/test/master/'));
     $result = $Git->find('all');
     $this->assertEqual($result[0]['Repo']['message'], 'Adding new file');
     $this->assertEqual($result[1]['Repo']['message'], 'Updating git ignore');
     // pr($Git->debug);
     //pr($Git->response);
     //die();
 }
Пример #2
0
        }
        if ($found) {
            header('HTTP/1.1 204 No Content');
        } else {
            header('HTTP/1.1 202 Accepted');
            Log::event('Received a pull webhook for an unhandled project');
            Log::client('This repository may not be synchronized');
        }
        return $found;
    }
}
Log::open($log);
$input = json_decode(file_get_contents('php://input'));
$conf = json_decode(file_get_contents($config));
if (isset($conf->git) && isset($conf->repositories)) {
    Git::config($conf->git);
    Git::repositories($conf->repositories);
} else {
    header('HTTP/1.1 500 Internal Server Error');
    Log::event('Malformed configuration');
    exit(1);
}
if (array_key_exists('HTTP_X_GITHUB_EVENT', $_SERVER) && isset($input->repository->ssh_url)) {
    // GitHub
    if ($_SERVER['HTTP_X_GITHUB_EVENT'] == 'push') {
        if (!Git::search($input->repository->ssh_url)) {
            Log::struct($input);
        }
    } else {
        Log::event('Received a GitHub webhook of unhandled kind (' . $_SERVER['HTTP_X_GITHUB_EVENT'] . ')');
        Log::struct($input);