Add admin support for pacakges with no history from the package gitHead.

This commit is contained in:
Richard Moore 2019-05-14 21:23:27 -04:00
parent 152dcda163
commit 22c16112df
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

@ -143,10 +143,23 @@ async function getDiff(filename, tag, nameOnly) {
if (tag == null) { tag = "HEAD"; } if (tag == null) { tag = "HEAD"; }
let cmd = [ "diff", "--name-only", tag, "--", filename ] let cmd = [ "diff", "--name-only", tag, "--", filename ]
if (!nameOnly) { cmd.splice(1, 1); } if (!nameOnly) { cmd.splice(1, 1); }
try {
let result = await git(cmd); let result = await git(cmd);
result = result.trim(); result = result.trim();
if (result === "") { return [ ]; } if (result === "") { return [ ]; }
return result.split("\n"); return result.split("\n");
} catch (error) {
// This tag does not exist, so compare against beginning of time
// This happens when there is a new history (like an orphan branch)
if (error.stderr.trim().match(/^fatal: bad object/)) {
console.log("Could not find history; showing all");
let cmd = [ "rev-list", "--max-parents=0", "HEAD" ];
let tag = await git(cmd);
return getDiff(filename, tag.trim(), nameOnly);
}
throw error;
}
} }
async function getUntracked(filename) { async function getUntracked(filename) {