From 48ccd4233932652afa11ad4e6b127153326ac3de Mon Sep 17 00:00:00 2001 From: Manabu Sugimoto Date: Thu, 30 Jun 2022 13:53:13 +0900 Subject: [PATCH] ci: Set safe.directory against tests repository Set `safe.directory` against `kata-containers/tests` repository before checkout because the user in the docker container is root, but the `tests` repository on the host machine is usually owned by the normal user. This works when we already have the `tests` repository which is not owned by root on the host machine and try to create a rootfs using Docker (`USE_DOCKER=true`). Fixes: #4561 Signed-off-by: Manabu Sugimoto --- ci/lib.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ci/lib.sh b/ci/lib.sh index f7f1eeeb751..3cb2c158f64 100644 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -18,6 +18,13 @@ clone_tests_repo() { if [ -d "$tests_repo_dir" ]; then [ -n "${CI:-}" ] && return + # git config --global --add safe.directory will always append + # the target to .gitconfig without checking the existence of + # the target, so it's better to check it before adding the target repo. + local sd="$(git config --global --get safe.directory ${tests_repo_dir} || true)" + if [ -z "${sd}" ]; then + git config --global --add safe.directory ${tests_repo_dir} + fi pushd "${tests_repo_dir}" git checkout "${branch}" git pull