function umc_github_link() { global $GITHUB; $repo = $GITHUB['repo']; $owner = $GITHUB['owner']; $client = umc_github_client_connect($owner, $repo); $out = ''; $paginator = new Github\ResultPager($client); $items = array('open_issues' => array('state' => array('state' => 'open'), 'fetch' => 'all'), 'closed_issues' => array('state' => array('state' => 'closed'), 'fetch' => 'all'), 'comments' => array('state' => 'comments', 'fetch' => 'show')); foreach ($items as $item => $I) { $api = $client->api('issue'); $parameters = array($owner, $repo, $I['state']); ${$item} = $paginator->fetchAll($api, $I['fetch'], $parameters); } $parameters = array('sha' => 'master', 'per_page' => 100); $commits = $client->api('repo')->commits()->all($owner, $repo, $parameters); $out .= '<script type="text/javascript" src="/admin/js/jquery.dataTables.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function() {jQuery("#shoptable_open").dataTable( {"autoWidth": false, "order": [[ 4 ]], "paging": false, "ordering": true, "info": false});;} ); jQuery(document).ready(function() {jQuery("#shoptable_closed").dataTable( {"autoWidth": false, "order": [[ 4 ]], "paging": false, "ordering": true, "info": false});;} ); jQuery(document).ready(function() {jQuery("#shoptable_commits").dataTable( {"autoWidth": false, "order": [[ 0 ]], "paging": false, "ordering": true, "info": false});;} ); </script> '; $tab1 = " <table class='unc_datatables' id='shoptable_open'>\r\n <thead>\r\n <tr><th>#</th><th>Title</th><th style='display:none;'>hidden data</th><th>Labels</th><th>Updated</th></tr>\r\n </thead>\r\n <tbody>" . umc_github_issue_body($open_issues, $comments) . "</tbody>\r\n </table>"; $tab2 = " <table class='unc_datatables' id='shoptable_closed'>\r\n <thead>\r\n <tr><th>#</th><th>Title</th><th style='display:none;'>hidden data</th><th>Labels</th><th>Updated</th></tr>\r\n </thead>\r\n <tbody>" . umc_github_issue_body($closed_issues, $comments) . "</tbody>\r\n </table>"; $tab3 = " <table class='unc_datatables' id='shoptable_commits'>\r\n <thead>\r\n <tr><th>Date</th><th>User</th><th>Message</th></tr>\r\n </thead>\r\n <tbody>" . umc_github_commit_body($commits) . "</tbody>\r\n </table>"; $o_count = count($open_issues); $c_count = count($closed_issues); $out .= umc_jquery_tabs(array("Open Issues ({$o_count})" => $tab1, "Closed Issues ({$c_count})" => $tab2, 'Commits' => $tab3)); return $out; }
protected function fetchExtensionsFromRepository() { $token = $_SESSION['github.token']; if (!$token) { throw new \Exception('no github token setup'); } $client = new \Github\Client(new \Github\HttpClient\CachedHttpClient(array('cache_dir' => $this->app->config('cache_dir') . 'githubapi-cache'))); $this->client = $client; $client->authenticate($token, null, \GitHub\Client::AUTH_URL_TOKEN); $pager = new \Github\ResultPager($client); $api = $client->api('repo'); $method = 'branches'; $params = ['php', 'php-src']; $branches = $pager->fetchAll($api, $method, $params); $branchesToFetch = []; foreach ($branches as $branch) { $currentBranchName = $branch['name']; if (strlen($currentBranchName) == 7) { if (preg_match('$PHP-([0-9])\\.([0-9])$', $currentBranchName, $matches)) { if ((int) $matches[1] < 5 || (int) $matches[2] < 4) { continue; } $branchesToFetch[$matches[0]] = $branch; } } } $this->branches = $branchesToFetch; $extensions = $this->fetchExtensionPerBranch(); return $extensions; }
if ($SHOW_MILESTONE) { print $COLOR_RED . ' update due date'; } $updateDueDate[] = ['org' => $config->org, 'repo' => $repo, 'number' => $milestone['number'], 'milestone' => $milestone['title'], 'state' => $milestone['state'], 'title' => $milestone['title'], 'description' => $milestone['description'], 'oldDueDate' => $milestone['due_on'], 'newDueDate' => $config->dueDates->{$milestone}['title'] . 'T04:00:00Z']; } if ($SHOW_MILESTONE) { print $NO_COLOR . PHP_EOL; } } if (in_array($repo, $config->skipLabels)) { continue; } if ($SHOW_LABEL) { print " Labels" . PHP_EOL; } $labels = $paginator->fetchAll($client->api('issues')->labels(), 'all', [$config->org, $repo]); uasort($labels, 'labelSort'); foreach ($labels as $label) { if ($label['name'][1] === '.') { $repositories[$repo]['labels'][$label['name']] = null; $repositories[$repo]['labels'][$label['name']] = ['color' => $label['color']]; if (strpos($label['name'], '-current') !== false) { $issues = $client->api('issue')->all($config->org, $repo, ['labels' => $label['name']]); $openCount = count($issues); if ($SHOW_LABEL) { if ($openCount === 0) { print $COLOR_GRAY; } else { print $COLOR_RED; } print " " . $label['name'] . ' ' . $openCount . $NO_COLOR . PHP_EOL;
private function _get_milestone_info($number) { $paginator = new Github\ResultPager($this->client); $issues = $paginator->fetchAll($this->client->api('issue'), 'all', array($this->org, $this->repo, array('milestone' => $number, 'state' => 'all'))); return $issues; }
freepbx::out("Done"); freepbx::outn("Checking you out into release/" . $options['updatemaster'] . "..."); $repo->checkout("release/" . $options['updatemaster']); freepbx::out("Done"); } $organizationApi = $client->api('organization'); $paginator = new Github\ResultPager($client); $parameters = array('freepbx'); $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters); $core = array(); foreach ($repos as $repo) { $core[] = $repo['name']; } $paginator = new Github\ResultPager($client); $parameters = array('FreePBX-ContributedModules'); $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters); $contrib = array(); foreach ($repos as $repo) { $contrib[] = $repo['name']; } if (in_array($rawname, $core)) { $org = "freepbx"; } elseif (in_array($rawname, $contrib)) { $org = "FreePBX-ContributedModules"; } else { exit; } $repo = $client->api('repo')->update($org, $rawname, array('name' => $rawname, 'description' => "Module of FreePBX (" . trim($name) . ") :: " . trim(strip_tags(str_replace(array("\r", "\n"), '', $description))), 'default_branch' => 'release/13.0', 'homepage' => 'http://www.freepbx.org', "has_issues" => false, "has_wiki" => false, "had_downloads" => false)); break; default: freepbx::showHelp('merge.php', $help);
$repositories = $client->api('repo')->show('purplapp', 'purplapp'); $repo_contributors = $client->api('repo')->contributors('purplapp', 'purplapp', false); // get the languages used in the repository $repo_language = $client->api('repo')->languages('purplapp', 'purplapp'); // $repo_language = new LanguageCollection($repo_language); // get the pull requests for the repository $repo_pull = $client->api('pull_request')->all('purplapp', 'purplapp', array('state' => 'all')); $repo_pull_comments_response = $client->getHttpClient()->get('/repos/purplapp/purplapp/comments'); $repo_pull_comments = Github\HttpClient\Message\ResponseMediator::getContent($repo_pull_comments_response); // get the releases from the repository $repo_releases = $client->api('repo')->releases()->all('purplapp', 'purplapp'); $repo_statistics = $client->api('repo')->statistics('purplapp', 'purplapp'); // get total number of commits $commitsApi = $client->repo()->commits(); $parameters = array('purplapp', 'purplapp', array('sha' => 'master')); $repo_commits = $paginator->fetchAll($commitsApi, 'all', $parameters); // get total number of issues $issuesApi = $client->issues(); $parameters = array('purplapp', 'purplapp', array('state' => 'all')); $repo_issues = $paginator->fetchAll($issuesApi, 'all', $parameters); // get total number of comments on issues $issuesCommentsApi = $client->issues()->comments(); $parameters = array('purplapp', 'purplapp', ''); $repo_issues_comments = $paginator->fetchAll($issuesCommentsApi, 'all', $parameters); // render the twig file return $app["twig"]->render("index.html.twig", compact("user", "repositories", "repo_contributors", "repo_language", "repo_issues", "repo_pull", "repo_commits", "repo_pull_comments", "repo_issues_comments", "repo_releases", "repo_issues_events", "repo_statistics")); }); // declare the routes $routes = array('home' => array('url' => '/', 'template' => 'index.html.twig')); // routes related stuff foreach ($routes as $routeName => $data) {
/** * コメントを取得する * * PR内のファイルに対するもの、PR自体に対するもの、両方を取得しマージする * * @param int $pr_number PR番号 * @return array $return_arr GithubAPI-Commentのレスポンスと、追加情報を含む配列 */ public function getComments($pr_number, $mode = self::COMMENT_GET_ALL) { // コメントは30個でページングされるため、それらを一気に取得するためのインスタンスを生成する $pager = new \Github\ResultPager($this->client); // コメントを取得する (PR内のファイルに対するもの) $pr_comments = []; if (self::COMMENT_GET_ALL === $mode or self::COMMENT_GET_FILE === $mode) { $pr_comments = $pager->fetchAll($this->client->api('pull_request')->comments(), 'all', array($this->repo_owner, $this->repo_name, $pr_number)); } // コメントを取得する (PR自体に対するもの) $issue_comments = []; if (self::COMMENT_GET_ALL === $mode or self::COMMENT_GET_PR === $mode) { $issue_comments = $pager->fetchAll($this->client->api('issue')->comments(), 'all', array($this->repo_owner, $this->repo_name, $pr_number)); } // コメントをマージして、日付昇順にする $comment_arr = array_merge($pr_comments, $issue_comments); usort($comment_arr, 'self::dateAscSort'); // 情報を追加する $is_new = true; $review_status = 0; $return_arr = []; foreach ($comment_arr as $comment) { if (1 === preg_match(GITHUB_PATTERN_IGNORE_USER, $comment['user']['login'])) { // このユーザのコメントは無視する continue; } $is_agree = $is_reset = $is_deco = false; if (isset($comment['diff_hunk'])) { // PR内のファイルに対するものであるとき $type = 'file'; } else { // PR自体に対するものであるとき $type = 'pr'; if (1 === preg_match(GITHUB_PATTERN_AGREE, $comment['body'])) { $is_agree = true; $review_status += 1; } if (1 === preg_match(GITHUB_PATTERN_RESET_AGREE, $comment['body'])) { $is_reset = true; $review_status = 0; } if (1 === preg_match(GITHUB_PATTERN_SHOW_URL, $comment['body'])) { $is_deco = true; } } $return_arr[] = ['is_new' => $is_new, 'is_decorate' => $is_deco, 'is_agree' => $is_agree, 'is_reset' => $is_reset, 'review_status' => $review_status, 'type' => $type, 'content' => $comment]; $is_new = false; } return $return_arr; }
exit; } // Convert the user's input to stdObjects so they're more fun $repo = (object) ['owner' => trim($ex[0]), 'name' => trim($ex[1])]; $auth = (object) $auth; // Authenticate (so that we can see private repos) $client = new \Github\Client(); $paginator = new \Github\ResultPager($client); try { $client->authenticate($auth->username, $auth->password, \Github\Client::AUTH_HTTP_PASSWORD); $issueApi = $client->api('issue'); $issues = []; // Get the closed issues first - limited to 30 $issues['closed'] = $issueApi->all($repo->owner, $repo->name, ['state' => 'closed']); // Get all the open issues $issues['open'] = $paginator->fetchAll($issueApi, 'all', [$repo->owner, $repo->name, ['state' => 'open']]); } catch (Github\Exception\RuntimeException $e) { echo 'Error: ' . $e->getMessage(); exit; } echo PHP_EOL; echo sprintf('%s open and %s closed issues pulled…', (string) count($issues['open']), (string) count($issues['closed'])); // Set up the header rows for the CSV $toWrite = [['url', 'number', 'title', 'status', 'assignee', 'milestone', 'created_at', 'updated_at', 'body']]; $prCount = 0; // Set up the data rows for the CSV foreach ($issues as $states) { foreach ($states as $issue) { // Strip out pull requests if (strpos($issue['html_url'], '/pull/')) { ++$prCount;