Commit 24c4a0e
committed
__init__: don't run refresh on import
Consumers of gitpython may not need to use it in all use cases, and may
want to be able to run (without using gitpython) in environments where
git is not available on PATH. While this can be worked around by setting
the GIT_PYTHON_REFRESH environment variable, adding special handling for
gitpython means that it can't be imported just like everything else in
an import block at the top of the module, and environment variables have
potentially undesired propagation behaviour.
Previously, it was also nontrivial to distinguish gitpython failing to
import because of missing git or because e.g. gitpython isn't installed
at all, because the exception that's raised is an ImportError without
further qualification (except in the error message).
Thus, we now no longer perform `refresh` at the module top level,
instead performing it lazily when an invocation of git is attempted.
This also allows some functionality that doesn't rely on the git command
to work without, e.g. ref listing.1 parent 2d4c541 commit 24c4a0e
4 files changed
+20
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
5 | 18 | | |
6 | 19 | | |
7 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | 295 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
857 | 857 | | |
858 | 858 | | |
859 | 859 | | |
860 | | - | |
| 860 | + | |
861 | 861 | | |
862 | 862 | | |
863 | 863 | | |
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
| 1578 | + | |
| 1579 | + | |
1578 | 1580 | | |
1579 | 1581 | | |
1580 | 1582 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments