Skip to content

Instantly share code, notes, and snippets.

@cordoval
Created January 29, 2014 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cordoval/8687397 to your computer and use it in GitHub Desktop.
Save cordoval/8687397 to your computer and use it in GitHub Desktop.
<?php
$token = '<yourtoken>';
// Find latest version
exec('git tag', $tags, $return);
usort($tags, 'version_compare');
$latest = array_pop($tags);
// Get commits since latest version
exec('git log ' . $latest . '...HEAD --oneline', $commits, $return);
// Filter commits that reference an issue
$issues = array();
foreach ($commits as $commit) {
if (preg_match('/[close|closes|fix|fixes] #([0-9]+)/i', $commit, $matches) && isset($matches[1])) {
$issues[] = $matches[1];
}
}
sort($issues);
// Query GitHub
$url = 'https://api.github.com/repos/sebastianbergmann/phpunit/issues/';
$headers = array(
'Authorization: token ' . $token,
'User-Agent: php-curl'
);
foreach ($issues as $id) {
$ch = curl_init($url . $id);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$issue = json_decode(curl_exec($ch), true);
print $id . ": " . $issue['title'] . " (" . $issue['url'] . ")\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment