-
Notifications
You must be signed in to change notification settings - Fork 934
Silent false success when git is not present #2136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Add callback function and error check to `execFile`. Fixes conventional-changelog/commitlint#2136
Wonder if we should tag this and #2118 with something like |
I missed this comment when it was made. I'm not sure to what extent it was directed at me, but I will drop my .02. Since the bug directly affects users of commitlint (and that is how it was found), I think a bug report here is definitely appropriate. That isn't to say there shouldn't also be a bug report in the |
I've been thinking about this for a few days. If the issue is definitely in I only would only recommend not doing it here if the fix is specific to commitlint but I'm guessing this could be a downstream problem for other packages that use |
Add callback function and error check to `execFile`. Fixes conventional-changelog/commitlint#2136
When git cannot be found in PATH and the user runs commitlint with parameters to read from the git log, commitlint exits with status 0 and no output.
Expected Behavior
When git is needed and cannot be found, commitlint should exit with a non-zero status and print an error.
Current Behavior
When git cannot be found in PATH, commitlint exits with status 0 and no output.
Affected packages
Possible Solution
Checking the exit status of git would be a good idea. That takes place in git-raw-commits; I will open a PR there soon.
Steps to Reproduce (for bugs)
cd /path/to/repo
touch foo && git add foo && git commit --no-verify -m 'Bad Commit Msg'
sudo mv /usr/bin/git /usr/bin/git.bak
commitlint --from HEAD~1
sudo mv /usr/bin/git.bak /usr/bin/git
Context
The reproduction steps above may make this seem like a convoluted edge case, but it is not too difficult to run into.
I encountered this bug when setting up CI jobs to run in an alpine linux container. The repository is made available to the container via a bind mount and git is not installed by default. I didn't realize at first that git was missing and was confused by commitlint succeeding when it should not.
Another way a dev could be affected by this is if git is uninstalled for some reason (accidental, troubleshooting, etc).
Your Environment
commitlint --version
@commitlint/[email protected]
git --version
git version 2.28.0
node --version
v14.11.0
The text was updated successfully, but these errors were encountered: