From feed81ea1a332dc415ea9010c8b5204473a51bdf Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Sun, 9 Jul 2017 19:53:38 +0200 Subject: Moved setup function into top level __init__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- git/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'git/__init__.py') diff --git a/git/__init__.py b/git/__init__.py index 8c31e309..cc45efe1 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -57,3 +57,20 @@ from git.util import ( # @NoMove @IgnorePep8 __all__ = [name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj))] + +#{ Initialize git executable path +def setup(path=None): + """Convenience method for setting the git executable path.""" + if not Git.refresh(path=path): + return + if not FetchInfo.refresh(): + return + +def refresh(path=None): + """Convenience method for refreshing the git executable path.""" + setup(path=path) +#} END initialize git executable path + +################# +setup() +################# -- cgit v1.2.3 From aba0494701292e916761076d6d9f8beafa44c421 Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Sun, 9 Jul 2017 22:07:31 +0200 Subject: Renamed refresh to setup and removed alias function & added unittest 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. --- git/__init__.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'git/__init__.py') diff --git a/git/__init__.py b/git/__init__.py index cc45efe1..7005cd60 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -58,19 +58,16 @@ from git.util import ( # @NoMove @IgnorePep8 __all__ = [name for name, obj in locals().items() if not (name.startswith('_') or inspect.ismodule(obj))] + #{ Initialize git executable path -def setup(path=None): +def refresh(path=None): """Convenience method for setting the git executable path.""" if not Git.refresh(path=path): return if not FetchInfo.refresh(): return - -def refresh(path=None): - """Convenience method for refreshing the git executable path.""" - setup(path=path) #} END initialize git executable path ################# -setup() +refresh() ################# -- cgit v1.2.3 From 79a36a54b8891839b455c2f39c5d7bc4331a4e03 Mon Sep 17 00:00:00 2001 From: "Odegard, Ken" Date: Tue, 25 Jul 2017 10:09:52 -0500 Subject: Minor additional cleanup 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. --- git/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'git/__init__.py') diff --git a/git/__init__.py b/git/__init__.py index 7005cd60..4ba55305 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -60,12 +60,19 @@ __all__ = [name for name, obj in locals().items() #{ Initialize git executable path +GIT_OK = None + def refresh(path=None): """Convenience method for setting the git executable path.""" + global GIT_OK + GIT_OK = False + if not Git.refresh(path=path): return if not FetchInfo.refresh(): return + + GIT_OK = True #} END initialize git executable path ################# -- cgit v1.2.3