{"record":{"id":"82f2c3646c6d0a22","repo":"midudev/autoskills","slug":"no-se-pudo-revertir-el-commit-de-release-autom-ticamente","errorCode":null,"errorMessage":"⚠️  No se pudo revertir el commit de release automáticamente","messagePattern":"⚠️  No se pudo revertir el commit de release automáticamente","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/autoskills/scripts/release.mjs","lineNumber":270,"sourceCode":"function rollbackRelease() {\n  console.log(\"\\n↩️  Revirtiendo cambios locales de la release fallida...\");\n\n  if (tagCreated) {\n    try {\n      run(`git tag -d v${newVersion}`, { cwd: REPO_ROOT });\n      console.log(`✅ Tag v${newVersion} eliminado`);\n    } catch {\n      console.warn(`⚠️  No se pudo eliminar el tag v${newVersion}`);\n    }\n  }\n\n  if (commitCreated) {\n    try {\n      run(`git reset --hard ${releaseStartHead}`, { cwd: REPO_ROOT });\n      console.log(\"✅ Commit de release revertido\");\n      return;\n    } catch {\n      console.warn(\"⚠️  No se pudo revertir el commit de release automáticamente\");\n    }\n  }\n\n  // If no release commit was created, restore touched files directly.\n  try {\n    writeFileSync(PKG_PATH, originalPkgContent);\n\n    if (originalChangelogContent === null) {\n      if (existsSync(CHANGELOG_PATH)) {\n        rmSync(CHANGELOG_PATH);\n      }\n    } else {\n      writeFileSync(CHANGELOG_PATH, originalChangelogContent);\n    }\n\n    run(\"git restore --staged package.json CHANGELOG.md\", { cwd: ROOT });\n    console.log(\"✅ package.json y CHANGELOG.md restaurados\");\n  } catch {","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/midudev/autoskills/blob/0ec725320d2137253ab2e68e7ba8a072148e741a/packages/autoskills/scripts/release.mjs#L252-L288","documentation":"In rollbackRelease(), after failing to delete the tag, the script attempts `git reset --hard <releaseStartHead>` to undo the release commit. If that git reset fails, it logs this warning and falls through to restoring the touched files (package.json, CHANGELOG.md) directly from their saved original contents. It signals the commit could not be reverted automatically.","triggerScenarios":"rollbackRelease() runs `git reset --hard ${releaseStartHead}` and the command exits non-zero — e.g. uncommitted changes blocking a hard reset, the commit ref no longer exists, or git errors — while commitCreated is true.","commonSituations":"A release failed after the release commit was made; the developer made new changes on top so the reset is risky/blocked; git hooks or a dirty index cause the reset to fail in CI.","solutions":["Manually revert: `git reset --hard <releaseStartHead>` (find the SHA in the script output or reflog via `git reflog`).","If the script fell through, confirm package.json and CHANGELOG.md were restored to their original content (`git diff`).","Clean the working tree (`git stash` or commit unrelated work) and re-run rollback so the hard reset can succeed."],"exampleFix":"// before\n# stuck with a bad release commit\ngit log -1  # release commit still in history\n// after\ngit reset --hard HEAD~1  # or the releaseStartHead SHA logged by the script","handlingStrategy":"try-catch","validationCode":"test -z \"$(git status --porcelain)\" && echo \"clean tree: hard reset safe\" || echo \"stash/commit changes first\"","typeGuard":null,"tryCatchPattern":"try {\n  run(`git reset --hard ${releaseStartHead}`, { cwd: REPO_ROOT });\n} catch (err) {\n  console.warn(`⚠️  Reset falló (${err.message}); ejecuta manualmente: git reset --hard ${releaseStartHead}`);\n}","preventionTips":["Keep the working tree clean during releases (the script already requires it) and avoid making changes while a release runs.","Note the releaseStartHead SHA printed by the script so manual reset is trivial.","Run releases in CI with a concurrency lock to avoid interleaved commits."],"tags":["git","release","rollback","commit","cleanup"],"backgroundTag":"git-command-failed","analyzedSha":"0ec725320d2137253ab2e68e7ba8a072148e741a","analyzedAt":"2026-09-15T14:12:31.090Z","contentChangedAt":"2026-09-15T14:12:31.090Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}