We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bbc922f commit aa01b74Copy full SHA for aa01b74
src/ansiblelint/file_utils.py
@@ -218,13 +218,17 @@ def get_yaml_files(options: Namespace) -> Dict[str, Any]:
218
219
def guess_project_dir() -> str:
220
"""Return detected project dir or user home directory."""
221
- result = subprocess.run(
222
- ["git", "rev-parse", "--show-toplevel"],
223
- stderr=subprocess.PIPE,
224
- stdout=subprocess.PIPE,
225
- universal_newlines=True,
226
- check=False,
227
- )
+ try:
+ result = subprocess.run(
+ ["git", "rev-parse", "--show-toplevel"],
+ stderr=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=True,
+ check=False,
228
+ )
229
+ except FileNotFoundError:
230
+ # if git is absent we use home directory
231
+ return str(Path.home())
232
233
if result.returncode != 0:
234
return str(Path.home())
0 commit comments