blob: 39efdda9c3c3bb70e213a934c609e27ab5280387 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
"""Single util module where Spack should get a git executable."""
import sys
from typing import Optional
import llnl.util.lang
import spack.util.executable as exe
@llnl.util.lang.memoized
def git(required: bool = False):
"""Get a git executable.
Arguments:
required: if ``True``, fail if ``git`` is not found. By default return ``None``.
"""
git: Optional[exe.Executable] = exe.which("git", required=required)
# If we're running under pytest, add this to ignore the fix for CVE-2022-39253 in
# git 2.38.1+. Do this in one place; we need git to do this in all parts of Spack.
if git and "pytest" in sys.modules:
git.add_default_arg("-c", "protocol.file.allow=always")
return git
|