Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Problem when checking for ignored files #1543

Closed
@Lightborne

Description

@Lightborne

Hello,
I stumbled on an issue that i think calls for an update to the GitPython'signored function.

I have a script that performs certain format checks on all files in a repository. Simple things like removing trailing whitespace. This script is written to only run on files that have been added to the repository, and it is written to not run on any untracked or ignored files.

My script generates a list of all the files in the workspace, and then it removes untracked and ignored files from that list. something like this

self.file_list # all the files in the repoself.ignored_files = repo.ignored(self.file_list) # should return all ignored files

Our company's working environment requires us to run several tools within the workspace that holds the repo. These tools all put their output into directories that we have ignored with.gitignore. But some of these tools create symbolic links within these directories.

Now, GitPython's implementation ofrepo.ignored is basically a wrapper around git's built incheck-ignore sub-command. When you try to check if a file behind a symbolic link is ignored using this sub-command, git throws a fatal error:

# This is the good case - git correctly tells me that both of these are ignored.git check-ignore ignore_file.txt ignore/target/ignore.txt ignore_file.txtignore/target/ignore.txt# This is the bad case - git simply bails with a fatal errorgit check-ignore ignore_file.txt ignore/link/ignore.txt fatal: pathspec 'ignore/link/ignore.txt' is beyond a symbolic link

GitPython'srepo.ignored implementation does not catch this fatal error. What it does is return an empty list.

So my script was failing because it was trying to format_check a bunch of stuff that was buried in an ignored directory!

I think what needs to happen is that therepo.ignored function needs to be enhanced to raise an exception when git throws this fatal error. Then, I could trap that exception and parse my file list, removing any entries that are hidden behind symbolic links.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp