|
22 | 22 | from glob import glob |
23 | 23 | from pathlib import Path |
24 | 24 | from mesonbuild.environment import Environment, detect_ninja |
25 | | -from mesonbuild.mesonlib import (MesonException, RealPathAction, get_meson_command, quiet_git, |
| 25 | +from mesonbuild.mesonlib import (GIT, MesonException, RealPathAction, get_meson_command, quiet_git, |
26 | 26 | windows_proof_rmtree, setup_vsenv, OptionKey) |
27 | 27 | from mesonbuild.msetup import add_arguments as msetup_argparse |
28 | 28 | from mesonbuild.wrap import wrap |
@@ -79,7 +79,36 @@ def is_git(src_root: str) -> bool: |
79 | 79 | Checks if meson.build file at the root source directory is tracked by git. |
80 | 80 | It could be a subproject part of the parent project git repository. |
81 | 81 | ''' |
82 | | - return quiet_git(['ls-files', '--error-unmatch', 'meson.build'], src_root)[0] |
| 82 | + if quiet_git(['ls-files', '--error-unmatch', 'meson.build'], src_root)[0]: |
| 83 | + return True |
| 84 | + |
| 85 | + if os.path.exists(os.path.join(src_root, '.git')): |
| 86 | + msg = 'Source tree looks like it may be a git repo, ' |
| 87 | + if not GIT: |
| 88 | + msg += 'but git is not installed!' |
| 89 | + if 'GITLAB_CI' in os.environ: |
| 90 | + msg += ' This is a gitlab bug.' |
| 91 | + else: |
| 92 | + msg += 'but git returned a failure. ' |
| 93 | + p, oe = quiet_git(['status'], src_root) |
| 94 | + if 'dubious ownership' in oe: |
| 95 | + # For a few years now, git has absolved itself of the responsibility to implement |
| 96 | + # robust, safe software. Instead of detecting the signs of a problematic scenario, |
| 97 | + # they have chosen to consider many legitimate and reasonable use cases as "dangerous", |
| 98 | + # and implemented the number one threat to security worldwide: alert fatigue. Having |
| 99 | + # done so, they then washed their hands of the matter and permanently tabled the |
| 100 | + # notion of adding fine-grained detection. This is not just useless, it is *worse* |
| 101 | + # than useless. |
| 102 | + # |
| 103 | + # In our case, the error is triply meaningless since we are already executing build |
| 104 | + # system commands from the same directory. Either way, reject the notion that git is |
| 105 | + # well designed or that its error messaging is a valid approach to the problem space. |
| 106 | + msg += 'This is a bug in git itself, please set `git config --global safe.directory "*"`' |
| 107 | + else: |
| 108 | + msg += 'meson.build may not have been committed to git?' |
| 109 | + mlog.warning(msg) |
| 110 | + return False |
| 111 | + |
83 | 112 |
|
84 | 113 | def is_hg(src_root: str) -> bool: |
85 | 114 | return os.path.isdir(os.path.join(src_root, '.hg')) |
|
0 commit comments