Skip to content

Adding setup for git executable#640

Merged
Byron merged 11 commits intogitpython-developers:masterfrom
kenodegard:adding_setup_for_git_executable
Sep 28, 2017
Merged

Adding setup for git executable#640
Byron merged 11 commits intogitpython-developers:masterfrom
kenodegard:adding_setup_for_git_executable

Conversation

@kenodegard
Copy link
Copy Markdown
Contributor

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:

>>> import git
WARNING: Bad git executable. The git executable must be specified in one of the following ways:
    (1) be included in your $PATH, or
    (2) be set via $GIT_PYTHON_GIT_EXECUTABLE, or
    (3) explicitly set via git.setup (or git.refresh).

All git commands will error until this is rectified.

>>> git.refresh("/usr/bin/git")
>>> git.Git().version()
'git version 2.11.0 (Apple Git-81)'
>>> 

The second is that this also means that the git executable can be dynamically refreshed at any time by simply calling refresh:

>>> import git
>>> git.Git.GIT_PYTHON_GIT_EXECUTABLE
'git'
>>> git.refresh("/usr/bin/git")
>>> git.Git.GIT_PYTHON_GIT_EXECUTABLE
'/usr/bin/git'

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants