buf: buf breaking in pre-commit will set core.bare to 'true' and failed
GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with “github.com/bufbuild/buf” or we will automatically close your issue, see the instructions above!)
No response
What’s up?
When I run pre-commit run --all-files or buf breaking --against "ssh://git@github.com/provistaai/protobuf.git#branch=main", It’s all right. But when I run git commit, It will auto set core.bare to ‘true’ and failed.
It’s a submodule and my .pre-commit-config.yaml is:
repos:
- repo: local
hooks:
- id: buf-format
name: Format Protobuf Files
entry: buf format -w
language: system
files: \.proto$
pass_filenames: false
- id: buf-breaking
name: Check Protobuf Breaking Changes
entry: buf breaking --against "ssh://git@github.com/provistaai/protobuf.git#branch=main"
language: system
files: \.proto$
pass_filenames: false
Is that a bug? What should I do? Thx a lot
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (7 by maintainers)
I’ve managed to create a repro of this issue, going to continue to investigate.
EDIT: I was able to create a commit with the fix I just opened a PR for, once we get that reviewed, merged, and released, hopefully this will help. Thanks!
I try it in linux but the result is the same:
@doriable I removed the repository and made a clean clone. But the result is the same.
The steps I took:
Step 1:
git clone git@github.com:Wu-Jiayang/test-a.gitandcd test-aStep 2:
git submodule update --init --recursiveandcd app/protosStep 3:
Step 4: add
// testin the end ofcontent.protoStep 5:
The
.git/modules/app/protos/configis:The issue is that the environment from the pre-commit in the submodule is passed to the buf command. This env contains the git variable
GIT_DIRwhich currently breaksbuf breaking. We have a fix to remove this in #3760. As a workaround for now you may be able to unset this variable before invokingbuf breaking.The root cause has been identified, we are working on resolving. This is currently an issue specific to submodules with repository-local hooks, I will keep this issue updated when a fix becomes available. Thanks!
Thank you for the detailed instructions, I followed them but was unable to reproduce the exact symptoms. Here are the steps I took:
If I do a reset and run
pre-committo test, I get the following:Which is fine, I adjusted the
.pre-commit-config.yamlto use https instead:Then I get:
Which is expected, since the
--againsttarget would have no proto files. But this is not the git failure that you’re experiencing. I did note that you are on Windows, so I also checked on a Windows machine. I also had to adjust the pre-commit hook to use https, and got valid failures:On Windows, I am running:
and on Mac, I am running:
My pre-commit version is 4.2.0.
Wu-Jiayang/test-aandWu-Jiayang/test-bare public repos. You can visit them.I have tried
1.52.1and1.47.0. Unfortunately, they both have the same problem. I will try to reproduce it on a new GitHub repository.