If cannot get current commit hash for a repo, mark it as up to date

19c18d54f5d7ee073be657e275e6b434510cfdf6

ceruleandeep <deep@cerulean.navy>

1 files changed, +10 -2Ignore whitespace
src/endpoints/extensions.js+10 -2
@@ -224,12 +224,20 @@ router.post('/version', jsonParser, async (request, response) => {
224224 return response.status(404).send(`Directory does not exist at ${extensionPath}`);
225225 }
226226
227+ let currentCommitHash;
228+ try {
229+ currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
230+ } catch (error) {
231+ // it is not a git repo, or has no commits yet, or is a bare repo
232+ // not possible to update it, most likely can't get the branch name either
233+ return response.send({ currentBranchName: null, currentCommitHash, isUpToDate: true, remoteUrl: null });
234+ }
235+
227236 const currentBranch = await git.cwd(extensionPath).branch();
228237 // get only the working branch
229238 const currentBranchName = currentBranch.current;
230239 await git.cwd(extensionPath).fetch('origin');
231- const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
240+ console.log(extensionName, currentBranchName, currentCommitHash);
232- console.log(currentBranch, currentCommitHash);
233241 const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
234242
235243 return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });