Report actual attempted Git command when Git.refresh fails by EliahKagan · Pull Request #1812 · gitpython-developers/GitPython (original) (raw)

Fixes #1809
Fixes #1811

This modifies Git.refresh to report the attempted Git command rather than always git even if a different command was used. This affects the command attribute of the GitCommandNotFound exception, as well as (and automatically) the text displayed as cmdline: since that is from that attribute.

It also expands and adds more tests of git.refesh (which calls Git.refresh) to encompass this behavior, verifying that they fail before #1809 is fixed and pass afterwards, as well as verify some behavior that was already established but not yet under test.

Since #1811 would otherwise be exacerbated by these changes, I've also made it so those tests roll back the global changes they make that may affect other test by calling git.refresh() with no arguments. I believe this can be considered to fix that issue.

There is a bit more information in the commit messages, including about why I've taken that approach to #1811, at least so far, rather than specifically capturing and restoring the pieces of state that are currently affected.

This PR also includes some minor refactoring and comment revision for readability in some code called by git.refresh that should make no behavioral change. This includes an improvement to the wording of the comment in Git.refresh discussed in review comments on #1810; the opportunity for this came closer than I'd predicted in #1810 (comment). (It might be possible to improve it further.)

Edit: Corrected "some behavior that was not established" to "some behavior that was already established but not yet under test".