GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adding setup for git executable by kenodegard · Pull Request #640 · gitpython-developers/GitPython

Conversation

@kenodegard

@kenodegard kenodegard commented Jul 9, 2017

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'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kenodegard added 5 commits July 9, 2017 18:35
@kenodegard
Preliminary implementation of setup/refresh functions
a962464
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.
@kenodegard
Moved setup function into top level __init__
feed81e
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.
@kenodegard
Renamed refresh to setup and removed alias function & added unittest
aba0494
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.
@kenodegard
Modified AUTHORS file
e8cb31d
Added my name to list.
@kenodegard
Added ability to silence initial warning
b56d677
Added the ability to silence the first refresh warning upon import by
setting an environment variable.
@codecov-io

codecov-io commented Jul 9, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@2af601d). Click here to learn what that means.
The diff coverage is 68.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 Files Coverage Δ
git/test/test_git.py 98.73% <100%> (ø)
git/cmd.py 83.29% <65.85%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2af601d...a56136f. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kenodegard kenodegard mentioned this pull request Jul 13, 2017
Fails on import with custom exception #637
Closed
kenodegard added 4 commits July 13, 2017 11:44
@kenodegard
Expanded ability of import
3430bde
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.
@kenodegard
Removed remaining references to git.setup function
4aa750a
Removed few remaining references to git.setup function (as it was
renamed to refresh).
@kenodegard
Renamed GIT_PYTHON_INITERR to GIT_PYTHON_REFRESH
2b3e769
Renamed and cleaned up variable names.
@kenodegard
Minor additional cleanup
79a36a5
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.
@kenodegard

kenodegard commented Jul 25, 2017

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kenodegard
Minor bug fixes
90dc03d
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.
@kenodegard kenodegard mentioned this pull request Aug 14, 2017
[GitPython >= 2.1.4] Can't import without git CLI #657
Closed
@Byron
Merge branch 'master' into adding_setup_for_git_executable
a56136f
@Byron
Byron merged commit 2eb6cf0 into gitpython-developers:master Sep 28, 2017
@Byron

Byron commented Sep 28, 2017

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

riley-martine pushed a commit to riley-martine/GitPython that referenced this pull request Dec 7, 2023
@Byron
Merge pull request gitpython-developers#640 from njalerikson/adding_s…
93e0938
…etup_for_git_executable

Adding setup for git executable
@EliahKagan EliahKagan mentioned this pull request Jan 17, 2024
Explanation makes unclear reference to "first" and "second" imports #1804
Closed
@EliahKagan EliahKagan mentioned this pull request Jan 24, 2024
Git.refresh warns to stdout and does not log #1808
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@kenodegard @codecov-io @Byron
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.