-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
bug: griffe check
from branch against main
cannot create a worktree
#337
Comments
Hi @szymonmaszke, thanks for the report.
Correct, any Git reference that you can checkout should work.
This might be at the center of the issue. I didn't know there were hooks that could when merely checking out a reference. I'm not sure how we could disable hooks while checking a ref out, there help for I don't think PDM and its PEP 582 setup has anything to do with this 🙂 (I've been a user myself). So, your example indeed reproduces the error, but I think that is expected. By the time you run |
Hey @pawamoy, thank you for a quick response! Pre-commit hooks
I was surprised as well, here are the hook types and this behavior is related to
As described in this SO answer you could do a checkout without running hooks (tested myself) via: > git -c core.hooksPath=/dev/null checkout <BRANCH> which might not work on Windows though due to Error
If I understand you correctly - I ran it against the And AFAICT these steps should work, correct me if I'm wrong (also you can treat is a reproducible case, please notice the comments as well): > mkdir foo
> cd foo
> git init
> git checkout -b a
> touch foo.py
> git add foo.py # this step should not matter
> griffe check --against master foo content of def my_func():
pass which returns: Traceback (most recent call last):
File "/home/XYZ/.local/bin/griffe", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/XYZ/.local/share/pipx/venvs/griffe/lib/python3.12/site-packages/_griffe/cli.py", line 562, in main
return commands[subcommand](**opts_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XYZ/.local/share/pipx/venvs/griffe/lib/python3.12/site-packages/_griffe/cli.py", line 477, in check
old_package = load_git(
^^^^^^^^^
File "/home/XYZ/.local/share/pipx/venvs/griffe/lib/python3.12/site-packages/_griffe/loader.py", line 883, in load_git
with tmp_worktree(repo, ref) as worktree:
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/home/XYZ/.local/share/pipx/venvs/griffe/lib/python3.12/site-packages/_griffe/git.py", line 127, in tmp_worktree
raise RuntimeError(f"Could not create git worktree: {process.stderr.decode()}")
RuntimeError: Could not create git worktree: fatal: invalid reference: master Additional info
Please let me know if I could be of any further assistance. |
Thanks! OK so that's a regression, and I know how to fix it (easy fix). |
Could you try again with Griffe installed from main branch 🙂? |
Thank you, now the checkout works correctly. I am not sure about output and breaking changes detection, I will raise a separate issue after a few more tests if necessary though. Thank you for the quick fix! |
Description of the bug
Maybe I am misusing
griffe
, but what I am trying to do:a
created frommain
griffe check --against main <package>
This returns the error
RuntimeError: Could not create git worktree: fatal: invalid reference: master
To Reproduce
Full traceback
Full traceback
Expected behavior
Changes introduced on the branch
a
to be displayed (as added functionfoo
or a-like)Environment information
Also tried with
griffe
installed withinpdm
, usingpep582
global as well as described hereAdditional context
tags
, my workflow doesn't use them at all, butgriffe
is, please correct me if I'm wrong, supposed to work with branches directlyRuntimeError: Could not create git worktree: Preparing worktree (new branch 'initial_release') fatal: a branch named 'initial_release' already exists
)main
, checking against brancha
), gotDeleted function foo
etc., as expecteda
and running againstmain
I got the error as below--no-verify
togit
command or some kind of flag to customize the behaviour?)pdm
might be the issue as thesitecustomize.py
(as described here), although I don't see a direct connection with thegit
command being ran bygriffe
All in all, it seems like the matching mechanism for
--against
seems to not recognize the argument and instead of checking out a given reference/branch intotmp
it tries to create a new branch (?)The text was updated successfully, but these errors were encountered: