Skip to content

Commit 75e12ca

Browse files
committed
ci: need to make Git trust the repo inside CI builds
Signed-off-by: WANG Xuerui <[email protected]>
1 parent e169d00 commit 75e12ca

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ trap _cleanup EXIT
5656
main() {
5757
mkdir -p "$OUT_DIR"
5858

59+
ensure_git_safety
5960
dump_config
6061
init_source_epoch
6162
provision_loong_rootfs "$ROOTFS_IMAGE_TAG" "$ROOTFS_DIR"

scripts/_utils.sh

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# this file is meant to be sourced
22

3+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
34
_IMAGE_TAG_PREFIX="ghcr.io/loongson-community"
45

56
builder_image_tag() {
@@ -65,6 +66,15 @@ echo_kv() {
6566
echo "$(_term yellow)${k}: $(_term cyan)$@$(_term reset)"
6667
}
6768

69+
ensure_git_safety() {
70+
[[ -n $CI ]] || return 0
71+
[[ -O "$REPO_ROOT" ]] && return 0
72+
73+
group "telling Git to consider the repo as safe"
74+
git config --global --add safe.directory "$REPO_ROOT"
75+
endgroup
76+
}
77+
6878
get_commit_time() {
6979
TZ=UTC0 git log -1 \
7080
--format='tformat:%cd' \

0 commit comments

Comments
 (0)