LAKITU: Add retry logic in git-r3 eclass

Add retry logic in git-r3 eclass in order to reduce the transient error at runtime. go/cos-rev/28982 added retry logic in git-2 but git-r3 is also used at some places. So, it's good to have retry logic while fetching repo in git-r3.

BUG=b/195965589
TEST=presubmit
RELEASE_NOTE=None

Change-Id: I263ecd887575199d18a4a430b498fa14f4dd4db5
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/eclass-overlay/+/29207
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Tested-by: Rayan Dasoriya <dasoriya@google.com>
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index 3fb1ccf..299e69c 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -743,7 +743,19 @@
 
 			set -- "${fetch_command[@]}"
 			echo "${@}" >&2
-			"${@}" || continue
+
+			local retry=3
+			local repo_fetched=false
+
+			while [[ $retry != 0 ]]; do
+				if "${@}"; then
+					repo_fetched=true
+					break
+				fi
+				retry=$(($retry-1))
+			done
+
+			[[ ${repo_fetched} ]] || continue
 
 			if [[ ${clone_type} == mirror || ${fetch_l} == HEAD ]]; then
 				# update our HEAD to match our remote HEAD ref