| 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 | } |
| 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 | const currentBranch = await git.cwd(extensionPath).branch(); | 236 | const currentBranch = await git.cwd(extensionPath).branch(); |
| 228 | // get only the working branch | 237 | // 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); |
| 234 | | 242 | |
| 235 | return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); | 243 | return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); |