Created
January 29, 2014 12:59
-
-
Save cordoval/8687397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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