fix: skip migrations and version check when called as git hook#545
Merged
di-sukharev merged 2 commits intodi-sukharev:masterfrom Mar 27, 2026
Merged
Conversation
Move isHookCalled() check before runMigrations() and checkIsLatestVersion() so that during git rebase, each pick commit exits immediately without expensive I/O and network calls. Also adds missing await on prepareCommitMessageHook() to properly handle async errors. Closes di-sukharev#493 Signed-off-by: majiayu000 <1835304752@qq.com>
Owner
|
@majiayu000 first of all thank you very much for your contribution <3 the code looks good, but an e2e test fails, could you pls look into it 🙏 |
Owner
|
@majiayu000 thank you 🙏 |
Signed-off-by: majiayu000 <majiayu000@users.noreply.github.com>
Owner
|
@majiayu000 thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #493
Problem
During
git rebase -i, opencommit'sprepare-commit-msghook runs for every pick commit. Even though the hook itself exits early whencommitSourceis set (e.g. during rebase),runMigrations()andcheckIsLatestVersion()execute first — adding network calls and file I/O per commit, making rebase painfully slow.Fix
Move the
isHookCalled()check beforerunMigrations()andcheckIsLatestVersion()in the CLI callback. When invoked as a git hook, we skip straight toprepareCommitMessageHook()without running migrations or version checks. These expensive operations only run for interactive CLI usage.Test Plan
npm run test:unit— all 25 tests passnpm run build— compiles cleanlygit rebase -i HEAD~3— each pick completes near-instantly