From 4d3400648eb7cfbb0b1ce95aa2cd4291ea65279c Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Mon, 17 Oct 2011 00:56:02 +0100 Subject: [PATCH] fixed git show lookup - required full path --- index.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/index.php b/index.php index d9745409..1c9c4fe9 100644 --- a/index.php +++ b/index.php @@ -31,29 +31,12 @@ // if sha specified, use that revision of licence $license = ''; if ($sha != "") { - try { - // TODO must cache and optimise this as it'll kill my server :-( - $gitCommitData = json_decode(@file_get_contents('https://api.github.com/repos/remy/mit-license/git/trees/' . $sha)); - if (isset($gitCommitData) && is_object($gitCommitData) && property_exists($gitCommitData, 'tree')) { - foreach ($gitCommitData->tree as $commit) { - if ($commit->path == 'LICENSE.html') { - $licenseData = json_decode(file_get_contents($commit->url)); - $license = base64_decode($licenseData->content); - break; - } - } - } - } catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; - } - /* $out = array(); // preg_replace should save us - but: please help me Obi Wan... - exec("git show " . $sha . ":LICENSE.html", $out, $r); + exec("/usr/local/bin/git show " . $sha . ":LICENSE.html", $out, $r); if ($r == 0) { $license = implode("\n", $out); - } - */ + } } // if we didn't manage to read one in, use latest