| Author | |
| Committer | |
| Tree | d813967b5baeb2b012fdeb74c9c3b18906da976f |
Fix git fetch loop in sai-builder The git helper script in the builder was using a refspec that could fail when the provided ref was a hash, or when the hash was not the tip of the branch. This caused the script to fail, and the builder to enter an infinite retry loop, consuming CPU. The script is modified to separate the fetching of the git object from the creation of the local ref. It now fetches the provided ref or hash, and then explicitly creates a local ref `ref-<hash>` pointing to the specific commit hash. This makes the process more robust and prevents the retry loop. | |
diff --git a/src/builder/b-mirror.c b/src/builder/b-mirror.c index f98e429..05bb29a 100644 --- a/src/builder/b-mirror.c +++ b/src/builder/b-mirror.c @@ -57,8 +57,12 @@ static const char * const git_helper_sh = " if [ ! -d \"$MIRROR_PATH/.git\" ]; then\n" " git init --bare \"$MIRROR_PATH\"\n" " fi\n" - " REFSPEC=\"$REF:ref-$HASH\"\n" - " git -C \"$MIRROR_PATH\" fetch \"$REMOTE_URL\" \"$REFSPEC\"\n" + " if [ \"$REF\" != \"$HASH\" ]; then\n" + " git -C \"$MIRROR_PATH\" fetch \"$REMOTE_URL\" \"$REF\"\n" + " else\n" + " git -C \"$MIRROR_PATH\" fetch \"$REMOTE_URL\" \"$HASH\"\n" + " fi\n" + " git -C \"$MIRROR_PATH\" update-ref \"ref-$HASH\" \"$HASH\"\n" "elif [ \"$OPERATION\" == \"checkout\" ]; then\n" " MIRROR_PATH=$1\n" " BUILD_DIR=$2\n"