Last active
September 3, 2015 22:04
-
-
Save zkat/217861 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| /** | |
| * latest_github_commits.php | |
| * Dumps a github commit report. | |
| */ | |
| /** | |
| * Dump a report of the latest commits for a github repo. | |
| * | |
| * @param string $owner Account name that owns the repo in question. | |
| * @param string $repo Project name of repository. | |
| * @param string $branch Branch name to fetch latest commits from | |
| * @param integer $num_commits Number of commits to dump (newest first) | |
| */ | |
| function latest_github_commits($owner, $repo, $branch, $num_commits) { | |
| // For formatting niceness. I haven't set up a template engine. | |
| $indent = " "; | |
| $newline = "<br />\n"; | |
| // Grabbin' some JSON. | |
| $url = "http://github.com/api/v2/json/commits/list/$owner/$repo/$branch"; | |
| $json = json_decode(file_get_contents($url), true); | |
| // Dumpin' sum HTML! Wooooo.... | |
| echo "<ul>\n"; | |
| foreach ($json['commits'] as $key=>$value) { | |
| if ($key >= $num_commits) { echo "</ul>"; return; } | |
| echo " <li>\n" . | |
| $indent . $value['message'] . $newline . | |
| $indent . "Author: " . $value['author']['name'] . " " . $value['author']['email'] . $newline . | |
| $indent . "Date: " . $value['committed_date'] . $newline . | |
| $indent . "id: " . $value['id'] . $newline . | |
| " </li>" . $newline; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment