public function __construct($accessToken, $throwExceptions = true) { $gitHubClient = new GitHubClient($accessToken); $gitHubClient->setThrowExceptions($throwExceptions); $this->issue = new Issue\Issue($gitHubClient); $this->pr = new PR\PR($gitHubClient); $this->repo = new Repo\Repo($gitHubClient); $this->gitHubClient = $gitHubClient; }
<?php require_once __DIR__ . '/client/GitHubClient.php'; $repos = array('server', 'installer'); $client = new GitHubClient(); foreach ($repos as $repo) { $client->setPage(); $client->setPageSize(2); $commits = $client->repos->commits->listCommitsOnRepository('kaltura', $repo); echo "Count: " . count($commits) . "\n"; foreach ($commits as $commit) { /* @var $commit GitHubCommit */ echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n"; } $commits = $client->getNextPage(); echo "Count: " . count($commits) . "\n"; foreach ($commits as $commit) { /* @var $commit GitHubCommit */ echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n"; } }
<?php date_default_timezone_set('America/Los_Angeles'); error_reporting(E_ALL); ini_set('display_errors', '1'); require_once '../../master/libraries/common.php'; require_once 'config.php'; require_once '../../master/Slim/Slim.php'; require_once '../../master/3scale/ThreeScaleClient.php'; require_once '../../master/client/GitHubClient.php'; require_once '../../master/parse/index.php'; $gclient = new GitHubClient(); $gclient->setCredentials($guser, $gpass); \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); // Incoming Keys $request = $app->request(); $Params = $request->params(); //var_dump($_GET); if (isset($Params['appid'])) { $appid = $Params['appid']; } else { $appid = ""; } if (isset($Params['appkey'])) { $appkey = $Params['appkey']; } else { $appkey = ""; } $client = new ThreeScaleClient($three_scale_provider_key); //echo "appid: " . $appid . "<br />";
<?php require_once dirname(__DIR__) . '/config.php'; require_once __DIR__ . '/github-php-client-master/client/GitHubClient.php'; $repos = array('civicrm/civicrm-core', 'civicrm/civicrm-packages', 'civicrm/civicrm-drupal', 'civicrm/civicrm-wordpress', 'civicrm/civicrm-joomla'); // Initialize database and prepared statements $dbh = new PDO('mysql:dbname=' . DBNAME . ';host=' . DBHOST, DBUSER, DBPASS); $stm_c = $dbh->prepare("\n INSERT INTO github_commit (repository, hash, author_login, author_date, committer_login, committer_date, message)\n VALUES (:repository, :hash, :author_login, :author_date, :committer_login, :committer_date, :message);\n"); $stm_u = $dbh->prepare("\n INSERT INTO github_user (id, login, name, company, email, location, avatar_url)\n VALUES (:id, :login, :name, :company, :email, :location, :avatar_url)\n ON DUPLICATE KEY UPDATE\n id=:id, login=:login, name=:name, company=:company, email=:email, location=:location, avatar_url=:avatar_url;\n"); // Initialize GitHub $client = new GitHubClient(); $client->setCredentials(GITHUB_USERNAME, GITHUB_PASSWORD); // Loop over each repository $users = array(); foreach ($repos as $repo) { echo "Repository {$repo} ..."; $new_commits = 0; $stm_c->bindParam(':repository', $repo); // Get last commit date in database $result = $dbh->query("SELECT MAX(author_date) FROM github_commit WHERE repository='{$repo}';")->fetch(); // Get commits from GitHub $parts = explode('/', $repo); $client->setPage(); // reinitialize the results pager $commits = $client->repos->commits->listCommitsOnRepository($parts[0], $parts[1], null, null, null, $result[0]); // Loop over each commit (paged) while (sizeof($commits)) { foreach ($commits as $commit) { /* @var $commit GitHubCommit */ // Write commit to database $stm_c->bindParam(':hash', $commit->getSha());
<?php $trancateQuery = "TRUNCATE TABLE statistic"; mysql_query($trancateQuery); $owner = preg_replace('/^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})?\\/([\\/\\w \\.-]*)?\\/([A-Za-z0-9.-]+)\\/?([a-z\\.]{2,6})*\\/?$/', '$4', $_POST['repository']); $repo = preg_replace('/^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})?\\/([\\/\\w \\.-]*)?\\/([A-Za-z0-9.-]+)\\/?([a-z\\.]{2,6})*\\/?$/', '$5', $_POST['repository']); $dateStart = $_POST['date_start']; $dateEnd = $_POST['date_end']; $client = new GitHubClient(); $client->setPage(); $commits = $client->repos->commits->listCommitsOnRepository($owner, $repo, null, null, null, $dateStart, $dateEnd); foreach ($commits as $commit) { $author = $commit->getAuthor()->getLogin(); $fullCommit = $client->repos->commits->getSingleCommit($owner, $repo, $commit->getSha()); foreach ($fullCommit->getFiles() as $file) { statistic_insert($file->getFilename(), $author); } } header('Location: /');
<?php require_once __DIR__ . '/client/GitHubClient.php'; $owner = 'EC-CUBE'; $repo = 'ec-cube'; $from = isset($_GET['from']) ? $_GET['from'] : date("Y-m-1 00:00:00"); $to = isset($_GET['to']) ? $_GET['to'] : date("Y-m-1 00:00:00"); $client = new GitHubClient(); $client->setPage(); $client->setPageSize(100); $data = array('state' => 'all'); $issues = $client->request("/repos/EC-CUBE/ec-cube/issues", 'GET', $data, 200, 'GitHubIssue', true); $summary = ''; foreach ($issues as $issue) { $summary .= method_exists($issue->getPullRequest(), 'getHtmlUrl') ? '[P]' : '[I]'; /* @var $issue GitHubIssue */ $summary .= "[" . $issue->getNumber() . "]: " . $issue->getState() . $issue->getTitle() . $issue->getUser()->getLogin() . $issue->getCreatedAt() . "<br />"; } echo $summary;
private static function client() { $client = new GitHubClient(); $client->setCredentials(GITHUB_USER, GITHUB_PASS); return $client; }
<?php require 'init.php'; $client = new GitHubClient($GLOBALS["github"]["username"], $GLOBALS["github"]["password"]); echo $client->getRepoList();
public function git_upload($file) { require_once __root__ . '/SimpleVers/system/github/client/GitHubClient.php'; $owner = $this->owner; $repo = $this->github_repo; $username = $this->github_user; $password = $this->github_pass; $tag_name = basename($file); $target_commitish = 'master'; $name = $this->name; $body = $this->description; $draft = false; $prerelease = false; $client = new GitHubClient(); $client->setDebug(false); $client->setCredentials($username, $password); try { $release = $client->repos->releases->create($owner, $repo, $tag_name, $target_commitish, $name, $body, $draft, $prerelease); $releaseId = $release->getId(); $filePath = $file; $contentType = 'application/php'; $name = basename($file); try { $client->repos->releases->assets->upload($owner, $repo, $releaseId, $name, $contentType, $filePath); echo "<img src='/SimpleVers/interface/images/success.png'><h2>File successfully uploaded.</h2>"; } catch (Exception $e) { echo "Error: " . $e; } } catch (Exception $e) { echo "<img src='/SimpleVers/interface/images/cloud.png'><h2>This file seems to be already uploaded.</h2>"; } }
* * @package WordPress * @subpackage Boilerplate * @since Boilerplate 1.0 */ $data = Timber::get_context(); $pi = new TimberPost(); $data['post'] = $pi; $data['body_class'] .= ' page-' . $pi->post_name; $template_file = 'page.twig'; if (file_exists($_SERVER['DOCUMENT_ROOT'] . $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css')) { $data['post']->css_file = $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css'; } $contribs = TimberHelper::transient('timber-contribs', function () { require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/tan-tan-kanarek/github-php-client/client/GitHubClient.php'; $client = new GitHubClient(); $auth = file_get_contents(__DIR__ . '/auth.json'); $auth = json_decode($auth); $client->setCredentials($auth->github->user, $auth->github->pass); $contribs = $client->repos->listContributors('jarednova', 'timber', array('per_page' => 100)); $extra = count($contribs) % 6; $total = count($contribs) - $extra; $contribs = TimberHelper::array_truncate($contribs, $total); $ret = array(); foreach ($contribs as $contrib) { $obj = new stdClass(); $obj->login = $contrib->getLogin(); $obj->avatar_url = $contrib->getAvatarUrl(); $ret[] = $obj; } return $ret;
/** * This function must be implemented, it is define in the abstract class * */ function render() { include LIBRARYPHP_PATH . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'github-php-client-master' . DIRECTORY_SEPARATOR . 'client' . DIRECTORY_SEPARATOR . 'GitHubClient.php'; $client = new GitHubClient(); $client->setPage(); $issuesPerPage = 100; $par = explode('/', $_REQUEST['params']); // if (isset($par[2])) { if ($par[2] == 'next') { $client->getNextPage(); } elseif ($par[2] == 'previous') { $client->getPreviousPage(); } else { $issuesPerPage = $par[2]; } } $client->setPageSize($issuesPerPage); //Authenticate user with username and password //$this->login($client); //Authenticate user TYPE OAUTH BASIC //$client->setAuthType(GitHubClientBase::GITHUB_AUTH_TYPE_OAUTH_BASIC); //$client->setOauthKey($_SESSION['signup_data']['token']); //This does the same this as $this->login($client);, but returns a 404 not sure why because the scope is user , repo (also added public_repo, repo_deployment, notifications, gist) //$client->setDebug(true); //Authenticate user TYPE OAUTH WEBFLOW $client->setAuthType(GitHubClientBase::GITHUB_AUTH_TYPE_OAUTH_WEBFLOW); $client->setOauthToken($_SESSION['signup_data']['token']); $issues = $client->issues->listIssues(OWNER, REPO); $row_content = ""; foreach ($issues as $issue) { /* @var $issue GitHubIssue */ $comments = $client->issues->comments->listCommentsOnAnIssue(OWNER, REPO, $issue->getNumber()); $labels = $client->issues->labels->listLabelsOnAnIssue(OWNER, REPO, $issue->getNumber()); //Get all Labels for this issue $priority = ""; $client_name = ""; $category = ""; if (!empty($labels)) { foreach ($labels as $label) { if (strlen($label->getName()) > 2) { $tempArr = explode(":", $label->getName()); switch ($tempArr[0]) { case 'P': $priority = $tempArr[1]; break; case 'C': $client_name = $tempArr[1]; break; case 'Cat': $category = $tempArr[1]; break; } } } } //Get all comments for this issue $comment_text = ""; if (!empty($comments)) { foreach ($comments as $comment) { if ($comment_text != "") { '<br><br>' . ($comment_text .= $comment->getBody()); } else { $comment_text .= $comment->getBody(); } } } $assignee = ""; if (!empty($issue->getAssignee())) { $assignee = $issue->getAssignee()->getLogin(); } $row_content .= '<tr> <td>' . $client_name . '</td><td>' . $issue->getTitle() . '</td><td>' . $issue->getBody() . '</td><td>#' . $issue->getNumber() . '</td><td>' . $priority . '</td><td>' . $category . '</td><td>' . $assignee . '</td><td>' . $comment_text . '</td><td>' . $issue->getState() . '</td> </tr>'; } include MODULE_PATH . 'Issue' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'issue.phtml'; }
public function reuploadRelease() { require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/client/GitHubClient.php'; $client = new GitHubClient(); $client->setDebug(true); $client->setAuthType(GitHubClient::GITHUB_AUTH_TYPE_BASIC); $client->setCredentials('daviddeutsch', trim(file_get_contents(__DIR__ . '/../github-oauth.token'))); foreach (glob(__DIR__ . '/tmp/*.zip') as $path) { $file = $path; } $release = $client->repos->releases->get('valanx', 'aec', 'latest'); $client->repos->releases->assets->upload('valanx', 'aec', $release->getId(), basename($file), 'application/zip', $file); }