Add admin support for pacakges with no history from the package gitHead.
This commit is contained in:
parent
152dcda163
commit
22c16112df
21
admin/git.js
21
admin/git.js
@ -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); }
|
||||||
let result = await git(cmd);
|
try {
|
||||||
result = result.trim();
|
let result = await git(cmd);
|
||||||
if (result === "") { return [ ]; }
|
result = result.trim();
|
||||||
return result.split("\n");
|
if (result === "") { return [ ]; }
|
||||||
|
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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user