Description
I noticed some issues that may cause problems in the hook: pre-push-update-version.js
await run('git', ['tag', '-d', latestTag]);
Deletes and recreates the latest tag, which changes tag identity and can break signed or annotated tags.
resp = await run('git', ['rev-list', '--tags', '--max-count=1']);
Selects the newest tagged commit instead of the highest semver tag, could cause version mismatches
may be undefined, so the script could exit successfully even when it fails
Proposed Changes:
1. Use semver-aware tag selection
Replace:
resp = await run('git', ['rev-list', '--tags', '--max-count=1']);
with :
resp = await run('git', ['tag', '--list', 'v*.*.*', '--sort=-v:refname']);
const latestTag = resp.stdout
.split('\n')
.map(tag => tag.trim())
.find(Boolean);
if (!latestTag) {
process.stderr.write(
'\x1b[0;31mNo version tags found matching v*.*.*. Aborting push.\x1b[0m\n'
);
process.exit(1);
}
2. Remove destructive tag rewrite
Remove:
await run('git', ['tag', '-d', latestTag]);
await run('git', ['tag', latestTag]);
Update the retry message to:
process.stderr.write(
'\x1b[0;32mPush again with: \x1b[0mgit push ' +
remoteName +
' ' +
currentBranch +
'\n'
);
3. Safe exit handling
Replace:
with:
console.error(e && e.message ? e.message : 'pre-push-update-version failed');
const exitCode = Number.isInteger(e && e.exit) ? e.exit : 1;
process.exit(exitCode);
Description
I noticed some issues that may cause problems in the hook: pre-push-update-version.js
Deletes and recreates the latest tag, which changes tag identity and can break signed or annotated tags.
Selects the newest tagged commit instead of the highest semver tag, could cause version mismatches
may be undefined, so the script could exit successfully even when it fails
Proposed Changes:
1. Use semver-aware tag selection
Replace:
with :
2. Remove destructive tag rewrite
Remove:
Update the retry message to:
3. Safe exit handling
Replace:
with: