Skip to content

Fix version bump pre-commit hook#33

Merged
anirudh-bijay-glean merged 4 commits into
mainfrom
anirudh/auto-version-bump-fix
Jun 30, 2026
Merged

Fix version bump pre-commit hook#33
anirudh-bijay-glean merged 4 commits into
mainfrom
anirudh/auto-version-bump-fix

Conversation

@anirudh-bijay-glean

@anirudh-bijay-glean anirudh-bijay-glean commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Update the pre-commit hook for automatic version bump (.githooks/pre-commit.d/02-auto-bump-version.sh) to update plugins/glean/.codex-plugin/plugin.json and plugins/glean/.cursor-plugin/plugin.json as well.

Why

The pre-commit hook was previously updating only plugins/glean/.codex-plugin/plugin.json.

Details

The script keeps the versions across the plugin manifests in lockstep. The larger number of possible cases here makes determining the target version complex. The target version is computed as follows:

Let $V_\rm{main}$ be the set of all valid versions (across all manifests) in the main branch and $V_\rm{current}$ be the set of all valid version strings taking into consideration the staged changes. Then,

  • if both $V_\rm{main}$ and $V_\rm{current}$ are empty, the script errors; else
  • if $V_\rm{main} = \emptyset$, $v = \rm{max} ~ V_\rm{current}$; else
  • if $V_\rm{current} = \emptyset$, $v = \rm{max}$ { $u + 0.0.1 \mid u \in V_\rm{main}$ }; else
  • $v = \rm{max}$ { $\rm{max} ~ V_\rm{current}, \rm{max}$ { $u + 0.0.1 \mid u \in V_\rm{main}$ } }
    where $v$ is the target version, $\rm{max}$ is defined relative to semver comparison, and $u + 0.0.1$ increments the patch version of $u$ by 1.

Versions are assumed to be of the form $x.y.z$ (no pre-release tags/build metadata).

Missing plugin manifests do not fail the hook; however, malformed JSON in the plugin manifests does.
Missing plugin manifests and malformed JSON in the plugin manifests fail the hook.

Code changes

  • Update 02-auto-bump-version.sh.
  • Update the shebang of shell scripts (01-rebuild-dist.sh, 02-auto-bump-version.sh, check-version-bump.sh, pack-plugin.sh) to use the environment Bash instead of the system Bash. (start.sh has been omitted.)

Comment thread .githooks/pre-commit.d/02-auto-bump-version.sh Outdated
Pros:
- Forces update of the hook when a manifest is deleted.

Cons:
- Forces multiple PRs when a manifest is created. The first PR will create the manifest, the second will update the hook.

The CI check is unaffected.
@anirudh-bijay-glean

anirudh-bijay-glean commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Addressed @swarup-padhi-glean's comments. The hook now errors on missing manifests in both main and the branch after staged changes. A couple of points to note:

Deleting a manifest: When deleting a manifest, the hook's MANIFESTS list must be updated before or along with deletion of the manifest file.

Adding a manifest: The manifest must be added and the change committed and merged to main first; only after this should the hook be updated. You may alternatively bypass the hook if the change is atomic, i.e., the plugin dist does not change (so that the hook for keeping the dist up-to-date need not run).

@anirudh-bijay-glean anirudh-bijay-glean merged commit 68ae29a into main Jun 30, 2026
2 checks passed
@anirudh-bijay-glean anirudh-bijay-glean deleted the anirudh/auto-version-bump-fix branch June 30, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants