feat: add 'undo' option to version command
This commit is contained in:
@@ -791,6 +791,7 @@ program.command('version').alias('v')
|
|||||||
.option('--list', 'List S4 tags (hides dev tags by default)')
|
.option('--list', 'List S4 tags (hides dev tags by default)')
|
||||||
.option('--prune', 'Prune old dev tags (keeps last 10)')
|
.option('--prune', 'Prune old dev tags (keeps last 10)')
|
||||||
.option('--all', 'Show all tags (including dev) when listing')
|
.option('--all', 'Show all tags (including dev) when listing')
|
||||||
|
.option('-u, --undo', 'Undo the last version bump (delete latest tag)')
|
||||||
.action(async (type, options) => {
|
.action(async (type, options) => {
|
||||||
await ensureRepo();
|
await ensureRepo();
|
||||||
if (!versionCmd) initializeComponents();
|
if (!versionCmd) initializeComponents();
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ class VersionCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.undo) {
|
||||||
|
await this.undoLastBump();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// --- Main Bump Logic ---
|
// --- Main Bump Logic ---
|
||||||
|
|
||||||
// 1. Get current version from Git Tags (SSOT)
|
// 1. Get current version from Git Tags (SSOT)
|
||||||
@@ -196,6 +201,44 @@ class VersionCommand {
|
|||||||
console.log(color.dim('Kept last 10 dev tags + all stable tags.'));
|
console.log(color.dim('Kept last 10 dev tags + all stable tags.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async undoLastBump() {
|
||||||
|
Progress.start('Undoing last version bump...');
|
||||||
|
|
||||||
|
// 1. Get current version (the one to delete)
|
||||||
|
const currentVersion = await this.s4.getCurrentVersion();
|
||||||
|
|
||||||
|
if (!currentVersion) {
|
||||||
|
Progress.stop('');
|
||||||
|
console.log(color.yellow('No S4 version tags found to undo.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Delete the tag
|
||||||
|
try {
|
||||||
|
await this.git.tag(['-d', currentVersion]);
|
||||||
|
Progress.stop('');
|
||||||
|
console.log(`${color.green('✔')} Deleted tag: ${color.cyan(currentVersion)}`);
|
||||||
|
} catch (e) {
|
||||||
|
Progress.error(`Failed to delete tag: ${e.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Revert .env files to *previous* version
|
||||||
|
// Now that the latest tag is gone, getCurrentVersion will return the previous one
|
||||||
|
const previousVersion = await this.s4.getCurrentVersion() || '0.0.0';
|
||||||
|
|
||||||
|
if (previousVersion) {
|
||||||
|
console.log(`Reverting environment to previous version: ${color.dim(previousVersion)}`);
|
||||||
|
const updatedFiles = this.updateEnvFiles(previousVersion);
|
||||||
|
if (updatedFiles.length > 0) {
|
||||||
|
console.log(`${color.green('✔')} Updated ${updatedFiles.join(', ')}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(color.dim('\nNote: If you already pushed the tag, you must verify deletion on remote:'));
|
||||||
|
console.log(` ${color.cyan(`git push --delete origin ${currentVersion}`)}`);
|
||||||
|
}
|
||||||
|
|
||||||
showInfo(versionStr) {
|
showInfo(versionStr) {
|
||||||
const parsed = S4Versioning.parse(versionStr);
|
const parsed = S4Versioning.parse(versionStr);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gims",
|
"name": "gims",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"description": "Git Made Simple – AI‑powered git helper with smart insights, stats & code review",
|
"description": "Git Made Simple – AI‑powered git helper with smart insights, stats & code review",
|
||||||
"author": "S41R4J",
|
"author": "S41R4J",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
Reference in New Issue
Block a user