Skip to content

Instantly share code, notes, and snippets.

@baturin
Created December 15, 2010 16:59
Show Gist options
  • Save baturin/742252 to your computer and use it in GitHub Desktop.
Save baturin/742252 to your computer and use it in GitHub Desktop.
git-rating
<?php
require_once('php-github-api/lib/phpGitHubApi.php');
$github = new phpGitHubApi();
$repositories = array(
array('jquery', 'jquery'), array('madrobby', 'scriptaculous'),
array('jashkenas', 'coffee-script'), array('yui', 'yui3'),
array('sstephenson', 'prototype'), array('mootools', 'mootools-core')
);
function add(&$array, $key, $value){
if (!array_key_exists($key, $array)) { $array[$key] = 0; }
$array[$key] += $value;
}
foreach ($repositories as $repository) {
list($user, $reponame) = $repository;
echo "Processing repository '$reponame' of user '$user'" . PHP_EOL;
echo 'Getting watchers' . PHP_EOL;
$watchers = $github->getRepoApi()->getRepoWatchers($user, $reponame);
foreach ($watchers as $watcher) { add($rating, $watcher, 10); }
echo 'Getting contributors' . PHP_EOL;
$contributors = $github->getRepoApi()->getRepoContributors($user, $reponame);
foreach ($contributors as $contributor) { add($rating, $contributor['login'], $contributor['contributions']); }
}
asort($rating);
foreach ($rating as $person => $ratingValue) {
echo implode(',', array($person, $ratingValue)) . PHP_EOL;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment