Skip to content
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: Temp dir name should be normalized #324

Closed
stevapple opened this issue Sep 27, 2024 · 2 comments
Closed

bug: Temp dir name should be normalized #324

stevapple opened this issue Sep 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@stevapple
Copy link

Description of the bug

When the branch name to checkout contains special characters (most notably, /), griffe will fail to create a temp directory for it.

To Reproduce

$ griffe check module_name -a origin/main

Full traceback

Full traceback
+ griffe check module -a origin/main
Traceback (most recent call last):
  File "/usr/local/bin/griffe", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/_griffe/cli.py", line 560, in main
    return commands[subcommand](**opts_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/_griffe/cli.py", line 475, in check
    old_package = load_git(
                  ^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/_griffe/loader.py", line 881, in load_git
    with tmp_worktree(repo, ref) as worktree:
  File "/usr/local/lib/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/_griffe/git.py", line 107, in tmp_worktree
    with TemporaryDirectory(prefix=f"{_WORKTREE_PREFIX}{repo_name}-{ref}-") as tmp_dir:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/tempfile.py", line 882, in __init__
    self.name = mkdtemp(suffix, prefix, dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/tempfile.py", line 384, in mkdtemp
    _os.mkdir(file, 0o700)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/griffe-worktree-package-origin/main-f19382b7'

Expected behavior

The tool should be able to check against arbitrary branch.

@stevapple stevapple added the unconfirmed This bug was not reproduced yet label Sep 27, 2024
@pawamoy
Copy link
Member

pawamoy commented Oct 1, 2024

Hi @stevapple, thanks for the report! Looks definitely like something that must be fixed. On it.

@pawamoy pawamoy added bug Something isn't working and removed unconfirmed This bug was not reproduced yet labels Oct 1, 2024
pawamoy added a commit that referenced this issue Oct 1, 2024
pawamoy added a commit that referenced this issue Oct 1, 2024
@pawamoy
Copy link
Member

pawamoy commented Oct 1, 2024

Fixed in v1.3.2 🙂

@pawamoy pawamoy closed this as completed Oct 1, 2024
clrpackages pushed a commit to clearlinux-pkgs/pypi-griffe that referenced this issue Oct 3, 2024
…on 1.3.2

commit acc8c6b61bee8e1beafb83970adfba5057b8051a
Author: Timothée Mazzucotelli <[email protected]>
Date:   Tue Oct 1 15:40:28 2024 +0200

    chore: Prepare release 1.3.2

commit 0821e6784e5a3aeb56020867c8b46f9477621ed3
Author: Timothée Mazzucotelli <[email protected]>
Date:   Tue Oct 1 15:28:00 2024 +0200

    fix: Normalize paths of temporary Git worktrees

    Issue-324: mkdocstrings/griffe#324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants