예제 #1
0
 public function updateCommits(Entity\Repo $repo)
 {
     $this->output->write(' commits');
     try {
         $commits = $this->github->getCommitApi()->getBranchCommits($repo->getUsername(), $repo->getName(), 'master');
     } catch (\phpGitHubApiRequestException $e) {
         if (404 == $e->getCode()) {
             return false;
         }
         throw $e;
     }
     $repo->setLastCommits(array_slice($commits, 0, 10));
     return $repo;
 }
예제 #2
0
파일: 00-git.php 프로젝트: robbiet480/hRepo
<?php

if ($slug == "git") {
    Content::$forcedTitle = "Git Update";
    if (count($params) > 0) {
        chdir(HR_ROOT);
        Content::setContent("\n\t\t\t<h1>Updating website from git...</h1>\n\t\t\t<pre>" . `echo Running git reset --hard && git reset --hard 2>&1 && echo Running git pull && git pull` . "</pre><br />\n\t\t\t<h3>Now pulling latest commit information from Github...</h3>\n\t\t");
        inclib('github/lib/phpGitHubApi.php');
        $phpGH = new phpGitHubApi();
        $phpGH->authenticate('lukegb', '3b4e0c11ee0681db035b0e885147e236', phpGitHubAPI::AUTH_HTTP_TOKEN);
        $latestCommits = $phpGH->getCommitApi()->getBranchCommits('robbiet480', 'hRepo', 'master');
        $gitCommit = array('long' => $latestCommits[0]['id'], 'short' => substr($latestCommits[0]['id'], 0, 7), 'userid' => $latestCommits[0]['author']['login'], 'commitdate' => $latestCommits[0]['committed_date']);
        file_put_contents(HR_ROOT . '/gitcommit.txt', serialize($gitCommit));
        Content::append('<p>Last git commit: ' . $gitCommit['long'] . ' by ' . $gitCommit['userid'] . '</p>');
    } else {
        Content::setContent("\n\t\t\t<h1>Authorisation code incorrect or missing</h2>\n\t\t\t<p>Git update did not go through.</p>\n\t\t");
    }
}
예제 #3
0
<?php

require_once dirname(__FILE__) . '/vendor/lime.php';
require_once dirname(__FILE__) . '/../lib/phpGitHubApi.php';
$t = new lime_test(5);
$username = '******';
$repo = 'php-github-api';
$branch = 'master';
$api = new phpGitHubApi(true);
$t->comment('Test ->listBranchCommits');
$commits = $api->getCommitApi()->getBranchCommits($username, $repo, $branch);
$t->is_deeply($api->listBranchCommits($username, $repo, $branch), $commits, 'Both new and BC syntax work');
$firstCommit = array_pop($commits);
$t->ok(isset($firstCommit['message']), 'Found master commits');
$t->comment('Test ->getFileCommits');
$commits = $api->getCommitApi()->getFileCommits($username, $repo, $branch, 'README');
$t->is_deeply($api->listFileCommits($username, $repo, $branch, 'README'), $commits, 'Both new and BC syntax work');
$firstCommit = array_pop($commits);
$t->is($firstCommit['message'], 'first commit', 'Found master README commits');
$t->comment('Test ->getCommit');
$commit = $api->getCommitApi()->getCommit($username, $repo, '726eac09a3b44411bd86');
$t->is($commit['message'], 'first commit', 'Found commit 726eac09a3b44411bd86');