Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdding setup for git executable #640
Merged
Conversation
Added one function (setup) and an alias (refresh simply calls setup). These functions give the developer one more way to configure the git executable path. This also allows the user to interactively adjust the git executable configured during runtime as these functions dynamically update the executable path for the entire git module.
Discovered that the remote module also relies on the git executable as such it also needs to be “refreshed” anytime the git executable is updated or changed. This was best solved by moving the setup function into the top level __init__ where the setup simply calls git.cmd.Git.refresh and git.remote.FetchInfo.refresh.
Renamed to simplify and avoid issue with nose tests trying to use `setup` as a setup for testing. Unittest implements basic test for refreshing with a bad git path versus a good git path.
Added my name to list.
Added the ability to silence the first refresh warning upon import by setting an environment variable.
Codecov Report
@@ Coverage Diff @@
## master #640 +/- ##
=========================================
Coverage ? 92.65%
=========================================
Files ? 61
Lines ? 10029
Branches ? 0
=========================================
Hits ? 9292
Misses ? 737
Partials ? 0
Continue to review full report at Codecov.
|
Renamed GIT_PYTHON_NOWARN to GIT_PYTHON_INITERR and added values for quiet import, warning import, and raise import. These respectively mean that no message or error is printed if git is non-existent, a plain warning is printed but the import succeeds, and an ImportError exception is raised.
Removed few remaining references to git.setup function (as it was renamed to refresh).
Renamed and cleaned up variable names.
Added additional information in the import warning/error that tells the user how to silence the warning/error. Also added a GIT_OK variable that allows for a quick check whether the refresh has succeeded instead of needing to test an actual git command.
@Byron what else would you need from me for this to be considered? |
Added tilde expansion as part of the refresh function. Added python version check such that we properly capture PermissionError in Python >=3 and OSError in Python <3.
Thanks a ton for your contribution, and my apologies for getting to this PR that late! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Added a convenience function called
refresh
. This functions accomplishes 2 things.The first is that now the user can dynamically set the git path AFTER importing GitPython. In the following example git is neither on the user's $PATH nor is $GIT_PYTHON_GIT_EXECUTABLE defined:
The second is that this also means that the git executable can be dynamically refreshed at any time by simply calling
refresh
: