Title: Have initial refresh use a logger to warn by EliahKagan · Pull Request #1815 · gitpython-developers/GitPython · GitHub
Open Graph Title: Have initial refresh use a logger to warn by EliahKagan · Pull Request #1815 · gitpython-developers/GitPython
X Title: Have initial refresh use a logger to warn by EliahKagan · Pull Request #1815 · gitpython-developers/GitPython
Description: Fixes #1808 Code changes in the git module: When the initial call to git.refresh that happens on import fails to find a git command and is configured to warn, it warns using a logger rather than with print. Although this is conceptually a warning, it is emitted with level CRTICAL, for the reasons given in ac50d8e (the commit in this PR that changes the tests for it). The message is changed to document this. A few more values, for existing GIT_PYTHON_REFRESH modes, are added as synonyms. No new modes are added, nor are their states expanded. The motivation for adding new synonyms is so log achieves logging, i.e., it is another way to say warn. But l is also added as its short form. (This might ordinarily be objected to on the grounds that, when written as l and not the also-recognized L, it could be confused with 1. Fortunately 1 also means warn, so 1 and l will have the same meaning anyway.) Furthermore, silent is added as a synonym of quiet, since silence is already recognized for that, so silent seems likely to be used by accident anyway. The reason I have not gone further at this time (as was discussed in the second part of this comment and in this reply) is it can be made more configurable in the future if it looks like that is valuable, but removing existing configurability could break more uses. Furthermore, because the level is CRITICAL which differs from that of any other GitPython messages, the better approach of controlling the effect in an application's own logging configuration may be sufficient. Test changes: Rename some existing tests more specifically, so they are not confused with new ones. These are the tests of subsequent (i.e., non-initial) calls to git.refresh when an explicit path argument is passed. Test subsequent refreshes performed with no arguments. That is, test calls to git.refresh with no arguments, without simulating the state of not yet having performed an initial refresh. This behavior is not changed in this pull request, but it makes sense to test it, doing so may avoid confusion with the different initial-refresh behavior when reading the tests, and the important subtlety of when relative paths are and aren't resolved is made clearer. Test an initial refresh. This is a refresh with no arguments that is performed on import, but to make the relationship to the other tests clearer, reduce test complexity, and make the tests run faster (since some of them run with all documented values of GIT_PYTHON_REFRESH), this simulates that state by setting Git.GIT_PYTHON_GIT_EXECUTABLE to None rather than starting a Python subprocess to do an import. This includes testing the behavioral change made in this PR and described above. Test the new synonyms of existing values for GIT_PYTHON_REFRESH (such as log for warn). I added the tests first. For the initial-refresh test, I first wrote it for the preexisting behavior, modified it for the desired behavior and saw it fail. Then I applied the changes, causing the tests to pass again. Those changes are based on, but not quite the same as, dc62096 as discussed in #1813 and #1808 (comment). There is some more information in commit messages, especially ac50d8e.
Open Graph Description: Fixes #1808 Code changes in the git module: When the initial call to git.refresh that happens on import fails to find a git command and is configured to warn, it warns using a logger rather than ...
X Description: Fixes #1808 Code changes in the git module: When the initial call to git.refresh that happens on import fails to find a git command and is configured to warn, it warns using a logger rather than ...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/1815
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:04a35308-084d-3916-6d47-45e49b248a79 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A4BC:F2D7A:57CBDC:7AA392:6968CC09 |
| html-safe-nonce | d9036ef55fd7654bb13b47dff407715e450ec54f392476917c8828c6bcab9346 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEJDOkYyRDdBOjU3Q0JEQzo3QUEzOTI6Njk2OENDMDkiLCJ2aXNpdG9yX2lkIjoiOTE1NjI3OTUwODM4Mzg3ODE1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 822b239c74184d1b87ed891e2eb4155402539c0ad26aada06a5d57eff707ba3a |
| hovercard-subject-tag | pull_request:1708386057 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/gitpython-developers/GitPython/pull/1815/files |
| twitter:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1771172?s=400&v=4 |
| og:image:alt | Fixes #1808 Code changes in the git module: When the initial call to git.refresh that happens on import fails to find a git command and is configured to warn, it warns using a logger rather than ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | af2d7af0cc84117fa10bf36808605ef68a335c9d8a804b9cdac55f8d77230b00 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cc844ab6ee0198cc2e2c142dcb8a5c2a61d48743 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width