Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
rewrite nodegit specific code using isomorphic-git (WIP) #47
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-guggisberg committed Dec 23, 2018
1 parent b5f8cf2 commit 94158f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ async function resolveBlob(dir, ref, pathName, includeUncommitted) {
})).oid;
}
// check working dir status
const status = await git.staus({ dir, filepath: pathName });
const status = await git.status({ dir, filepath: pathName });
if (status.endsWith('unmodified')) {
return (await git.readObject({
dir,
oid: commitSha,
filepath: pathName,
format: 'content',
})).id;
})).oid;
}
if (status.endsWith('absent') || status.endsWith('deleted')) {
const err = new Error(`Not found: ${pathName}`);
err.code = git.E.TreeOrBlobNotFoundError;
throw err;
}
// return blob id representing working dir file
const content = await fse.readFile(path.resolve(dir, pathName));
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function resolveBlobFromTree(repo, tree, filePath, serveUncommitted) {
const blob = await tree.getEntry(filePath)
.then(entry => entry.getBlob())
.catch(() => null);
const localBlob = serveUncommitted ? await Git.Blob.createFromWorkdir(repo, fil¡ePath)
const localBlob = serveUncommitted ? await Git.Blob.createFromWorkdir(repo, filePath)
.then(oid => Git.Blob.lookup(repo, oid))
.catch(() => null) : null;

Expand Down

0 comments on commit 94158f1

Please sign in to comment.