Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding setup for git executable#640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

kenodegard
Copy link
Contributor

Added a convenience function calledrefresh. 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 gitWARNING: 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 callingrefresh:

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

Added one function (setup) and an alias (refresh simply calls setup).These functions give the developer one more way to configure the gitexecutable path. This also allows the user to interactively adjust thegit executable configured during runtime as these functions dynamicallyupdate the executable path for the entire git module.
Discovered that the remote module also relies on the git executable assuch it also needs to be “refreshed” anytime the git executable isupdated or changed. This was best solved by moving the setup functioninto the top level __init__ where the setup simply callsgit.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 forrefreshing 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 bysetting an environment variable.
@codecov-io
Copy link

codecov-io commentedJul 9, 2017
edited
Loading

Codecov Report

❗ No coverage uploaded for pull request base (master@2af601d).Click here to learn what that means.
The diff coverage is68.88%.

Impacted file tree graph

@@            Coverage Diff            @@##             master     #640   +/-   ##=========================================  Coverage          ?   92.65%           =========================================  Files             ?       61             Lines             ?    10029             Branches          ?        0           =========================================  Hits              ?     9292             Misses            ?      737             Partials          ?        0
Impacted FilesCoverage Δ
git/test/test_git.py98.73% <100%> (ø)
git/cmd.py83.29% <65.85%> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update2af601d...a56136f. Read thecomment docs.

Renamed GIT_PYTHON_NOWARN to GIT_PYTHON_INITERR and added values forquiet import, warning import, and raise import. These respectively meanthat no message or error is printed if git is non-existent, a plainwarning is printed but the import succeeds, and an ImportErrorexception is raised.
Removed few remaining references to git.setup function (as it wasrenamed to refresh).
Renamed and cleaned up variable names.
Added additional information in the import warning/error that tells theuser how to silence the warning/error. Also added a GIT_OK variablethat allows for a quick check whether the refresh has succeeded insteadof needing to test an actual git command.
@kenodegard
Copy link
ContributorAuthor

@Byron what else would you need from me for this to be considered?

Added tilde expansion as part of the refresh function. Added pythonversion check such that we properly capture PermissionError in Python>=3 and OSError in Python <3.
@ByronByron merged commit2eb6cf0 intogitpython-developers:masterSep 28, 2017
@Byron
Copy link
Member

Thanks a ton for your contribution, and my apologies for getting to this PR that late!

riley-martine pushed a commit to riley-martine/GitPython that referenced this pull requestDec 7, 2023
…etup_for_git_executableAdding setup for git executable
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@kenodegard@codecov-io@Byron

[8]ページ先頭

©2009-2025 Movatter.jp