mirror of
https://github.com/samsonjs/mit-license.git
synced 2026-04-27 15:07:42 +00:00
fixed git show lookup - required full path
This commit is contained in:
parent
b41ffeb8d1
commit
4d3400648e
1 changed files with 2 additions and 19 deletions
19
index.php
19
index.php
|
|
@ -31,29 +31,12 @@
|
||||||
// if sha specified, use that revision of licence
|
// if sha specified, use that revision of licence
|
||||||
$license = '';
|
$license = '';
|
||||||
if ($sha != "") {
|
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();
|
$out = array();
|
||||||
// preg_replace should save us - but: please help me Obi Wan...
|
// 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) {
|
if ($r == 0) {
|
||||||
$license = implode("\n", $out);
|
$license = implode("\n", $out);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we didn't manage to read one in, use latest
|
// if we didn't manage to read one in, use latest
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue