Title: Problem when checking for ignored files · Issue #1543 · gitpython-developers/GitPython · GitHub
Open Graph Title: Problem when checking for ignored files · Issue #1543 · gitpython-developers/GitPython
X Title: Problem when checking for ignored files · Issue #1543 · gitpython-developers/GitPython
Description: Hello, I stumbled on an issue that i think calls for an update to the GitPython's ignored function. I have a script that performs certain format checks on all files in a repository. Simple things like removing trailing whitespace. This s...
Open Graph Description: Hello, I stumbled on an issue that i think calls for an update to the GitPython's ignored function. I have a script that performs certain format checks on all files in a repository. Simple things l...
X Description: Hello, I stumbled on an issue that i think calls for an update to the GitPython's ignored function. I have a script that performs certain format checks on all files in a repository. Simple thin...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1543
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problem when checking for ignored files","articleBody":"Hello,\r\nI stumbled on an issue that i think calls for an update to the GitPython's `ignored` function.\r\n\r\nI 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.\r\n\r\nMy 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\r\n \r\n self.file_list # all the files in the repo\r\n self.ignored_files = repo.ignored(self.file_list) # should return all ignored files \r\n\r\nOur 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.\r\n\r\nNow, GitPython's implementation of `repo.ignored` is basically a wrapper around git's built in `check-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:\r\n\r\n # This is the good case - git correctly tells me that both of these are ignored.\r\n git check-ignore ignore_file.txt ignore/target/ignore.txt \r\n ignore_file.txt\r\n ignore/target/ignore.txt\r\n\r\n # This is the bad case - git simply bails with a fatal error\r\n git check-ignore ignore_file.txt ignore/link/ignore.txt \r\n fatal: pathspec 'ignore/link/ignore.txt' is beyond a symbolic link\r\n\r\nGitPython's `repo.ignored` implementation does not catch this fatal error. What it does is return an empty list. \r\n\r\nSo my script was failing because it was trying to format_check a bunch of stuff that was buried in an ignored directory!\r\n\r\nI think what needs to happen is that the `repo.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.","author":{"url":"https://github.com/Lightborne","@type":"Person","name":"Lightborne"},"datePublished":"2023-01-20T20:02:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1543/GitPython/issues/1543"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e5874363-5bb3-bf61-a7a6-404ab717e55f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A34E:1788C3:44ED6:59056:69827B16 |
| html-safe-nonce | 31cfbd49c2c2bdf04ea1e770a770981234d418333d477a0bf9139f36f6295ec5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzRFOjE3ODhDMzo0NEVENjo1OTA1Njo2OTgyN0IxNiIsInZpc2l0b3JfaWQiOiI0MDM2NDM1NDY1MTI0MDg0NTAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 06d656a463bade70b57c65b313a47b6b34fdc42f292269539a4c3f943da5de5e |
| hovercard-subject-tag | issue:1551377091 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/1543/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd44fb2bd708c040b08788019d96ead5c683ebaf7e0cb7c7308d25124b085900/gitpython-developers/GitPython/issues/1543 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd44fb2bd708c040b08788019d96ead5c683ebaf7e0cb7c7308d25124b085900/gitpython-developers/GitPython/issues/1543 |
| og:image:alt | Hello, I stumbled on an issue that i think calls for an update to the GitPython's ignored function. I have a script that performs certain format checks on all files in a repository. Simple things l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lightborne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 502ff2009aec8671c806fca4ec6d758f90b6b96901b01d5f0ed23cc438efdf0f |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 91faf9ddeaffa60920f2a429a182532df340bb9a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width