We have an existing git repository with a .Net solution. We are adding a web application to the mix. The web application(angular) is in a specific subfolder.
We did install some pre-post commit hooks, to ensure the file is properly linted. Everything works fine when committing with VS Code or Source tree. But when I try to commit something directly from Visual Studio, I get this error:
/usr/bin/env: 'bash': No such file or directory
Is there a way to make it work?
For reference, here are my hooks:
post-checkout
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
git lfs post-checkout "$@"
post-commit
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
git lfs post-commit "$@"
post-merge
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
git lfs post-merge "$@"
cd ./Src/Frontend
npx git-pull-run --pattern "package-lock.json" --command "npm install"
pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
cd ./Src/Frontend
npm run lint
pre-push
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
git lfs pre-push "$@"
There has to be a way of using to pre/post commit hooks while still being able to commit in VS Code and VS, right? What should I do?
CodePudding user response:
Check your %PATH%
first, which should include C:\Program Files\Git\bin
, where bash.exe
resides.
Or modify, for testing, the shebang directive with:
#!C:/Program\ Files/Git/git-bash.exe