| 224 | 224 | return response.status(404).send(`Directory does not exist at ${extensionPath}`); |
| 225 | 225 | } |
| 226 | 226 | |
| 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 | 236 | const currentBranch = await git.cwd(extensionPath).branch(); |
| 228 | 237 | // get only the working branch |
| 229 | 238 | const currentBranchName = currentBranch.current; |
| 230 | 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 | 241 | const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath); |
| 234 | 242 | |
| 235 | 243 | return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); |