u-boot/tools/patman/project.py
Simon Glass 212ed6bdb7 patman: Deal with git safe-directory warning
When running tests where the .git directory is not owned by the current
user, various warnings are produced and the tests fail. This happens in
CI.

For patman itself, modify the gitutil.get_top_level() function to return
None in this case. Ensure that the warning is not shown, since it creates
about 1000 lines of output.

For checkpatch, the same warning is produced even though --no-tree is
given. Suppress that as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-27 10:07:42 +01:00

28 lines
726 B
Python

# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2012 The Chromium OS Authors.
#
import os.path
from u_boot_pylib import gitutil
def detect_project():
"""Autodetect the name of the current project.
This looks for signature files/directories that are unlikely to exist except
in the given project.
Returns:
The name of the project, like "linux" or "u-boot". Returns "unknown"
if we can't detect the project.
"""
top_level = gitutil.get_top_level()
if (not top_level or
os.path.exists(os.path.join(top_level, "include", "u-boot"))):
return "u-boot"
elif os.path.exists(os.path.join(top_level, "kernel")):
return "linux"
return "unknown"