LAKITU: Add retry logic in git eclass

Add retry logic in git eclass in order to reduce the transient error at runtime

BUG=b/195965589
TEST=presubmit
RELEASE_NOTE=None

Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/eclass-overlay/+/28982
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Change-Id: I71e34e40bcd7623aeeb1f1b8b8e59d1bb93073cd
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/eclass-overlay/+/29663
diff --git a/eclass/git-2.eclass b/eclass/git-2.eclass
index b938345..e230983 100644
--- a/eclass/git-2.eclass
+++ b/eclass/git-2.eclass
@@ -329,12 +329,17 @@
 	EGIT_REPO_URI_SELECTED=""
 	for repo_uri in ${EGIT_REPO_URI}; do
 		debug-print "${FUNCNAME}: git clone ${EGIT_LOCAL_OPTIONS} \"${repo_uri}\" \"${EGIT_DIR}\""
-		if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
-			# global variable containing the repo_name we will be using
-			debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
-			EGIT_REPO_URI_SELECTED="${repo_uri}"
-			break
-		fi
+		local retry=3
+		while [[ $retry != 0 ]]; do
+			if git clone ${EGIT_LOCAL_OPTIONS} "${repo_uri}" "${EGIT_DIR}"; then
+				# global variable containing the repo_name we will be using
+				debug-print "${FUNCNAME}: EGIT_REPO_URI_SELECTED=\"${repo_uri}\""
+				EGIT_REPO_URI_SELECTED="${repo_uri}"
+				break
+			fi
+			retry=$(($retry-1))
+		done
+		[[ -n ${EGIT_REPO_URI_SELECTED} ]] && break
 	done
 
 	[[ ${EGIT_REPO_URI_SELECTED} ]] \