-
-
Notifications
You must be signed in to change notification settings - Fork 934
Use of GIT_REPO env-var for setting Repo path in 2.0.9 #535
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That should be the expected behavior, env-variables taking precedence over code, correct?
Can you clarify a bit on that? |
I'm not so sure. Code is more explicit than an implicit override by an environment variable. Also, with the env var taking precedence over code, you can't do things like have multiple Repo instances with different paths.
The following pre-commit script would have previously worked on
|
Here's a demonstration of
|
+ Improve documentation on the contructor `path` parameter.
Indeed 26bb778 introduced a bug in the |
Concerning @cheshirekow useful example, it demonstrates that the But there is another issue here:
[1] https://longair.net/blog/2011/04/09/missing-git-hooks-documentation/ |
|
I have a conflicting gut-feeling there... The general idea for the priority of the configuration params is borrowed from the way command-line tools configure themselves; usually there is a list of configuration sources (rough description follows):
So based on the list above, BUT gitpython is a not a Cmd-line tool but a Library, and function arguments ( Taking a strict stance on that would mean that env-vars (such as Any ideas on this? |
@ethereon Thanks for all the effort you put into this issue ! Personally I believe that the current behaviour is unintuitive, as the path specifically provided of course has the final say. Ideally, GitPython would not have started adding so much magic as to expand @ankostis regarding the env-vars that are set when GitPython executes hooks: Maybe this is another instance of GitPython getting into its own way as it now has to chase a flying, and in this case, undocumented bullet. However, to me it looks like another issue that should probably be addressed independently of this one if there is any need. |
FIX gitpython-developers#535 according to Byron's comment: gitpython-developers#535 (comment)
Done, with a slight twist: env-var used if path
Of course; and is not urgent at all.
I would say that this depends on situation:
The solution you both described is respecting both cases, and have implemented in 5fac8d4. |
FIX #535: expand also GIT_DIR var on Repo-construction
This change in
2.0.9
is a bit problematic:path
is explicitly provided to the constructor, theGIT_DIR
environment variable is used insteadGIT_DIR
is set to.git
by default. This will result inself.git_dir
being set to.git
(os.path.abspath
instead ofos.path.normpath
would fix this). Consequently, subsequent commands fails (eg:repo.git.status()
)The text was updated successfully, but these errors were encountered: