@@ -66,6 +66,25 @@ function start_ssh_agent {
66
66
fi
67
67
}
68
68
69
+ function repo_sync_helper {
70
+ _repo_retries=4
71
+ _repo_extra_args=" "
72
+ for i in $( seq $_repo_retries ) ; do
73
+ if run timeout --preserve-status $@ $_repo_extra_args ; then
74
+ break
75
+ else
76
+ status " repo [$i /$_repo_retries ] failed with error $? "
77
+ if [ $i -eq $_repo_retries ]; then
78
+ exit 1
79
+ fi
80
+ _sleep=$(( $i * 2 ))
81
+ status " sleeping ${_sleep} s and trying again"
82
+ sleep $_sleep
83
+ _repo_extra_args=" --verbose"
84
+ fi
85
+ done
86
+ }
87
+
69
88
function repo_sync {
70
89
status " Repo syncing sources..."
71
90
@@ -74,39 +93,10 @@ function repo_sync {
74
93
status " Adding git config extraheader for $domain /factories"
75
94
git config --global http.https://${domain} /factories.extraheader " $( cat /secrets/git.http.extraheader) "
76
95
fi
77
- _repo_extra_args=" "
78
- for i in $( seq 4) ; do
79
- if run repo init $_repo_extra_args --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES} ; then
80
- break
81
- fi
82
- _repo_extra_args=" --verbose"
83
- status " repo init failed with error $? "
84
- if [ $i -eq 4 ]; then
85
- exit 1
86
- fi
87
- status " sleeping and trying again"
88
- sleep $(( $i * 2 ))
89
- done
90
- _repo_extra_args=" "
91
- for i in $( seq 4) ; do
92
- if run timeout 4m repo sync $_repo_extra_args ; then
93
- break
94
- fi
95
- _repo_extra_args=" --verbose"
96
- if [ $? -eq 124 ] ; then
97
- msg=" Command timed out"
98
- if [ $i -ne 4 ] ; then
99
- msg=" ${msg} , trying again"
100
- else
101
- status ${msg}
102
- exit 1
103
- fi
104
- status ${msg}
105
- sleep $(( $i * 2 ))
106
- else
107
- exit $?
108
- fi
109
- done
96
+
97
+ repo_sync_helper 1m repo init --repo-rev=v2.35 --no-clone-bundle -u $* ${REPO_INIT_OVERRIDES}
98
+ repo_sync_helper 4m repo sync
99
+
110
100
if [ -d " $archive " ] ; then
111
101
status " Generating pinned manifest"
112
102
repo manifest -r -o $archive /manifest.pinned.xml
0 commit comments