mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
If cannot get current commit hash for a repo, mark it as up to date
This commit is contained in:
@@ -224,12 +224,20 @@ router.post('/version', jsonParser, async (request, response) => {
|
|||||||
return response.status(404).send(`Directory does not exist at ${extensionPath}`);
|
return response.status(404).send(`Directory does not exist at ${extensionPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentCommitHash;
|
||||||
|
try {
|
||||||
|
currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
|
||||||
|
} catch (error) {
|
||||||
|
// it is not a git repo, or has no commits yet, or is a bare repo
|
||||||
|
// not possible to update it, most likely can't get the branch name either
|
||||||
|
return response.send({ currentBranchName: null, currentCommitHash, isUpToDate: true, remoteUrl: null });
|
||||||
|
}
|
||||||
|
|
||||||
const currentBranch = await git.cwd(extensionPath).branch();
|
const currentBranch = await git.cwd(extensionPath).branch();
|
||||||
// get only the working branch
|
// get only the working branch
|
||||||
const currentBranchName = currentBranch.current;
|
const currentBranchName = currentBranch.current;
|
||||||
await git.cwd(extensionPath).fetch('origin');
|
await git.cwd(extensionPath).fetch('origin');
|
||||||
const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
|
console.log(extensionName, currentBranchName, currentCommitHash);
|
||||||
console.log(currentBranch, currentCommitHash);
|
|
||||||
const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
|
const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
|
||||||
|
|
||||||
return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });
|
return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });
|
||||||
|
Reference in New Issue
Block a user