Commit 1ecfad6
committed
git: Exit clearly when in a "dubious" directory
I hit a _very_ hard to diagnose issue today after switching part of a
CI environment. It turns out that due to non-privileged container
magic the CI step was not running as the user that cloned the repo.
This manifested as the sdist generated during this step just not
having a few extra data files; but the build still passed. So several
steps later, suddenly files have just vanished from the sdist, which
of course is not something that is checked for and so testing blows up
in very strange ways.
After I understood what was going on, there is a _tiny_ little message
hidden amongst the logs that gives a hint of what's going on.
...
writing requirements to src/proj.egg-info/requires.txt
writing top-level names to src/proj.egg-info/top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'src/proj.egg-info/SOURCES.txt'
writing manifest file 'src/proj.egg-info/SOURCES.txt'
...
What is actually happening is that if you run git you get "git status
fatal: detected dubious ownership in repository at '/..proj'". This
is the well-known CVE-2022-24765 issue where trusting a `.git` config
dir from another user causes problems. In
6a3bb96 all the calls in
setuptools_scm/git.py were updated to use `--git-dir` directly -- git
will not complain if you have told it to explicitly trust the config
dir like this.
However, there are calls in _file_finders/git.py to find the top-level
that are not using this. It silently (modulo an easily missed log)
skips adding files when this occurs.
I can not see that this would ever be the behaviour you would want.
If it had of exploded telling me the git call failed, it would have
short-cut all of the problem finding.
This adds an explicit match on the static part of this git failure
message and raises a SystemExit if it hits. A test case that mocks
such a situation is added.
Closes: #784
Signed-off-by: Ian Wienand <[email protected]>1 parent e56b78f commit 1ecfad6
File tree
3 files changed
+49
-0
lines changed- docs
- src/setuptools_scm/_file_finders
- testing
3 files changed
+49
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
625 | 628 | | |
626 | 629 | | |
627 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
861 | 863 | | |
862 | 864 | | |
863 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
0 commit comments