Repository navigation
fix(hook): run prepare-commit-msg without node in PATH - #600
Open
SajjadPSavoji wants to merge 1 commit into
Open
SajjadPSavoji wants to merge 1 commit into
SajjadPSavoji wants to merge 1 commit into
Conversation
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.
oco hook setsymlinked the CLI as the hook, which relies on#!/usr/bin/env node. Git GUI clients like the vscode source control panel often start hooks without node inPATH, so commits failed withenv: node: No such file or directory.Now
setwrites a small/bin/shlauncher that runs the CLI with the absolute, shell-quotedprocess.execPathand CLI path. It also exportsOCO_GIT_HOOK=1soisHookCalledstill detects hook mode, since argv[1] is nowcli.cjs. Old symlinks and outdated launchers get replaced, runningsetagain says already set, and a foreign or dangling hook is refused onsetand left alone onunset. The README now says to rerunoco hook setafter switching or removing a node version.Thanks @di-sukharev for the approach.
Tests: the new unit test in
test/unit/githook.test.tsruns the launcher with a bogusPATHand paths with spaces and quotes. Intest/e2e/cliBehavior.test.tsI added tests for replacing a legacy symlink and an outdated launcher, keeping a foreign or dangling hook, and a realgit commitafterhook setwithPATH=/usr/bin:/bin. I ran the unit tests ingithook.test.tsandsetup.test.ts, plusbiome checkandtsc --noEmit. I did not run the full suite, so the e2e tests were not run here.Fixes #422