Server logging utilize tracking branch

- Use tracking branch instead of hardcoded "origin"
- Remove dev logging message if not on "staging" or "release"
This commit is contained in:
Wolfsblvt 2024-04-02 22:51:43 +02:00
parent 514c40228c
commit 3ccb63dd21
2 changed files with 4 additions and 5 deletions

View File

@ -479,10 +479,7 @@ const setupTasks = async function () {
console.log(); console.log();
console.log(`SillyTavern ${version.pkgVersion}`); console.log(`SillyTavern ${version.pkgVersion}`);
console.log(version.gitBranch ? `Running '${version.gitBranch}' (${version.gitRevision}) - ${version.commitDate}` : ''); console.log(version.gitBranch ? `Running '${version.gitBranch}' (${version.gitRevision}) - ${version.commitDate}` : '');
if (version.gitBranch && !['staging', 'release'].includes(version.gitBranch)) { if (version.gitBranch && !version.isLatest && ['staging', 'release'].includes(version.gitBranch)) {
console.log('INFO: Currently running a dev branch.');
console.log(` If this isn't a dev environment, consider switching via 'git switch staging' or 'git switch release'.`);
} else if (version.gitBranch && !version.isLatest) {
console.log('INFO: Currently not on the latest commit.'); console.log('INFO: Currently not on the latest commit.');
console.log(` Run 'git pull' to upate. If you have any conflicts, run 'git reset --hard' and 'git pull' to reset your branch.`) console.log(` Run 'git pull' to upate. If you have any conflicts, run 'git reset --hard' and 'git pull' to reset your branch.`)
} }

View File

@ -92,9 +92,11 @@ async function getVersion() {
gitBranch = await git.cwd(cwd).revparse(['--abbrev-ref', 'HEAD']); gitBranch = await git.cwd(cwd).revparse(['--abbrev-ref', 'HEAD']);
commitDate = await git.cwd(cwd).show(['-s', '--format=%ci', gitRevision]); commitDate = await git.cwd(cwd).show(['-s', '--format=%ci', gitRevision]);
const trackingBranch = await git.cwd(cwd).revparse(['--abbrev-ref', '@{u}']);
// Might fail, but exception is caught. Just don't run anything relevant after in this block... // Might fail, but exception is caught. Just don't run anything relevant after in this block...
const localLatest = await git.cwd(cwd).revparse(['HEAD']); const localLatest = await git.cwd(cwd).revparse(['HEAD']);
const remoteLatest = await git.cwd(cwd).revparse([`origin/${gitBranch}`]); const remoteLatest = await git.cwd(cwd).revparse([trackingBranch]);
isLatest = localLatest === remoteLatest; isLatest = localLatest === remoteLatest;
} }
} }