Skip to content

Conversation

@Julusian
Copy link
Member

@Julusian Julusian commented Dec 17, 2025

About the Contributor

This pull request is posted on behalf of myself.

Type of Contribution

This is a: Bug fix

Current Behavior

While making a release of a library, I was confused that it didnt make a commit. I then discovered it had made a tag, based on the existing commit.

This is because husky is misconfigured and is causing the commit to fail.

New Behavior

This ensures that when a commaand fails, it will cause a rejection and result in an error.

Skip running any commit hooks when making the commit, as they shouldn't matter and cause unexpected failures in this simple command

Testing Instructions

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

This PR fixes two critical issues in the version update automation script:

Error Handling Fix
The script now uses Node's util.promisify for child_process.exec (const execPromise = promisify(exec)), replacing a custom Promise wrapper that previously resolved with error objects instead of rejecting. This restores standard Promise semantics so failing shell commands properly reject and surface errors.

Commit Hook Bypass
The automatic release commit now includes --no-verify (git commit --no-verify -m "chore(release): v${nextVersion}") to bypass git hooks (e.g., husky). This prevents misconfigured hooks from causing commits to fail while tags were still created, ensuring the version bump commit and tag are created together.

Formatting
Code uses tabs for indentation consistent with project standards.

@Julusian Julusian requested a review from a team as a code owner December 17, 2025 16:19
@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Walkthrough

Replaced a custom Promise wrapper with Node's promisify(exec) (named execPromise), removed the manual exec wrapper, switched all command executions to execPromise, and added --no-verify to the git commit command to bypass pre-commit hooks.

Changes

Cohort / File(s) Summary
Version Update Tooling
bin/updateVersion.mjs
Replaced manual exec Promise wrapper with promisify(exec)execPromise; removed the old wrapper; switched command calls to execPromise; added --no-verify to the git commit invocation

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰
A tiny shell, a gentle hop,
Promises now resolve or stop.
Commits sped past the hooks that pry,
A quiet version, soft and spry. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes the two main changes: fixing command failure handling and adding --no-verify to git commits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

}

await execPromise(`git commit -m "chore(release): v${nextVersion}"`)
await execPromise(`git commit --no-verify -m "chore(release): v${nextVersion}"`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on this - I think if there is a pre-commit that fails, something weird is going on and we shouldn't proceed with making a new version until it's fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh... this is only commiting a readme and the package.json so the precommit isn't all that relevant imo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came out of a case where husky was complaining about something in a repository and caused it to fail. All I was doing was making a release after a PR or two had been merged, so fixing husky was more effort than it was worth.

I don't mind too much if we don't have this no-verify, as it will now fail rather than continue through to creating the tag, and I could manually complete the steps. But I also don't see any harm in including it here, especially as the expected behaviour is that the lint-staged will conclude that all the staged files are ignored

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @bin/updateVersion.mjs:
- Around line 8-10: promisify(exec) returns an object { stdout, stderr } not a
string, so update all call sites of execPromise to use the stdout string before
applying string methods: either destructure const { stdout } = await
execPromise(cmd) or replace (await execPromise(cmd)) with (await
execPromise(cmd)).stdout; apply this to uses around execPromise where rawDiff is
produced, where rawDiff.split('+++') is called, and where gitHash and
commitDateStr are trimmed so you call .trim() on their stdout-derived strings
(e.g., gitHash = (await execPromise(...)).stdout.trim()).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95a5fc7 and 0f52164.

📒 Files selected for processing (1)
  • bin/updateVersion.mjs
🔇 Additional comments (1)
bin/updateVersion.mjs (1)

186-186: LGTM: --no-verify flag appropriately bypasses hooks for automated commits.

This correctly addresses the issue where husky misconfiguration could cause commits to fail silently, resulting in tags being created without corresponding commits.

Comment on lines +8 to +10
import { promisify } from 'node:util'

const execPromise = promisify(exec)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: promisify(exec) returns { stdout, stderr }, not a string.

The previous custom wrapper likely returned just the stdout string. With promisify(exec), the result is an object. All existing usages that call string methods (.split(), .trim()) on the result will fail at runtime.

Affected lines:

  • Line 55: (await execPromise(...)).split('\n')
  • Line 59-60: rawDiff.split('+++')
  • Line 98, 101: gitHash.trim()
  • Line 99-100: commitDateStr.trim()
🐛 Proposed fix: access `.stdout` property on all command results
-const tags = cli.flags.lastTag || (await execPromise('git tag -l --sort=-v:refname')).split('\n')
+const tags = cli.flags.lastTag || (await execPromise('git tag -l --sort=-v:refname')).stdout.split('\n')
-const rawDiff = await execPromise(`git log --format=+++%s__%b__%h__%H ${lastTag}..HEAD`)
+const rawDiff = (await execPromise(`git log --format=+++%s__%b__%h__%H ${lastTag}..HEAD`)).stdout
-	const gitHash = await execPromise(`git rev-parse --short HEAD`)
-	const commitDateStr = await execPromise(`git log -1 --pretty=format:%ct HEAD`)
+	const gitHash = (await execPromise(`git rev-parse --short HEAD`)).stdout
+	const commitDateStr = (await execPromise(`git log -1 --pretty=format:%ct HEAD`)).stdout
🤖 Prompt for AI Agents
In @bin/updateVersion.mjs around lines 8 - 10, promisify(exec) returns an object
{ stdout, stderr } not a string, so update all call sites of execPromise to use
the stdout string before applying string methods: either destructure const {
stdout } = await execPromise(cmd) or replace (await execPromise(cmd)) with
(await execPromise(cmd)).stdout; apply this to uses around execPromise where
rawDiff is produced, where rawDiff.split('+++') is called, and where gitHash and
commitDateStr are trimmed so you call .trim() on their stdout-derived strings
(e.g., gitHash = (await execPromise(...)).stdout.trim()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants