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

19c18d54f5d7ee073be657e275e6b434510cfdf6

ceruleandeep <deep@cerulean.navy>

1 files changed, +10 -2Showing whitespace changes
src/endpoints/extensions.js+10 -2
@@ -224,12 +224,20 @@ router.post('/version', jsonParser, async (request, response) => {
224 return response.status(404).send(`Directory does not exist at ${extensionPath}`);224 return response.status(404).send(`Directory does not exist at ${extensionPath}`);
225 }225 }
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
227 const currentBranch = await git.cwd(extensionPath).branch();236 const currentBranch = await git.cwd(extensionPath).branch();
228 // get only the working branch237 // get only the working branch
229 const currentBranchName = currentBranch.current;238 const currentBranchName = currentBranch.current;
230 await git.cwd(extensionPath).fetch('origin');239 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);
233 const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);241 const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
234242
235 return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });243 return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });