-
Notifications
You must be signed in to change notification settings - Fork 482
Fix git-lfs unnecessary hook installation #1416
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
base: main
Are you sure you want to change the base?
Fix git-lfs unnecessary hook installation #1416
Conversation
f20c448
to
a95c315
Compare
a95c315
to
a2774d7
Compare
a2774d7
to
3a2c97e
Compare
Fix an issue where git lfs install was running unnecessarily in repositories without LFS files, causing hooks to be installed when they shouldn't be. Changes: - Update src/git-lfs/install.sh to properly check for empty git lfs ls-files output - Add comprehensive test (test/git-lfs/noLfsFiles.sh) to verify hooks are not installed when no LFS files are present - Update test scenarios to include the new test case The fix changes the condition from checking command exit status to checking if the output is empty, preventing unnecessary hook installation in non-LFS repos.
3a2c97e
to
2c73a25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where Git LFS hooks were being installed unnecessarily in repositories without LFS files. The fix changes the detection logic from checking command exit status to verifying if the output is empty, preventing hook installation in non-LFS repositories.
- Modified the LFS detection logic in the install script to check for empty output instead of command exit status
- Added a comprehensive test case to verify hooks are not installed when no LFS files are present
- Updated test scenarios to include the new test case for repositories without LFS files
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/git-lfs/install.sh | Updated LFS detection logic to check for empty output and separate error handling |
test/git-lfs/noLfsFiles.sh | Added new test to verify no hooks are installed in repositories without LFS files |
test/git-lfs/scenarios.json | Added test scenario configuration for repositories without LFS files |
Comments suppressed due to low confidence (1)
test/git-lfs/noLfsFiles.sh:22
- This test redirects stderr to /dev/null which may hide important error messages that could help diagnose test failures. Consider capturing and checking the error output separately or allowing it to be visible during test execution.
check "git lfs ls-files returns empty output" test -z "$(git lfs ls-files 2>/dev/null)"
Fix an issue where
git lfs install
was running unnecessarily in repositories without LFS files, causing hooks to be installed when they shouldn't be.Changes:
src/git-lfs/install.sh
to properly check for emptygit lfs ls-files
outputtest/git-lfs/noLfsFiles.sh
) to verify hooks are not installed when no LFS files are presentThe fix changes the condition from checking command exit status to checking if the output is empty, preventing unnecessary hook installation in non-LFS repos.
Related issues/PRs:
git-lfs
not actually runninggit lfs install
#1379The changes above introduced new problems in the following scenario:
Starting a dev container from the default
universal
image with the git-lfs featureAdd
devcontainer.json
without the git-lfs feature and rebuild the containerEncounter the following warnings/errors when trying to use
git checkout
,commit
, orpush
: