File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,9 +167,30 @@ fetch_repos.yaml() {
167167 local repo=${3:- $REPOSFILE_REPO }
168168
169169 local baseurl=" https://raw.githubusercontent.com/${repo} /${ref} "
170+ local output_dir
171+ output_dir=$( dirname " $output_file " )
170172
171- $CURL " ${CURL_OPTS[@]} " \
172- -L \
173- " ${baseurl} /etc/repos.yaml" \
174- -o " $output_file "
173+ if $CURL " ${CURL_OPTS[@]} " -f -L " ${baseurl} /etc/repos.yaml" -o " $output_file " ; then
174+ return 0
175+ fi
176+
177+ echo " HTTPS download failed; falling back to git clone of ${repo} @${ref} "
178+
179+ (
180+ cd " $output_dir " || exit 1
181+
182+ # Clone into same directory but with unique PID to only copy repos.yaml
183+ local clone_dir=" .repos_clone_$$ "
184+
185+ if git clone --depth 1 --branch " $ref " " https://github.com/${repo} .git" " $clone_dir " ; then
186+ if [ -f " ${clone_dir} /etc/repos.yaml" ]; then
187+ cp " ${clone_dir} /etc/repos.yaml" " $output_file "
188+ echo " repos.yaml successfully retrieved via git clone"
189+ fi
190+ rm -rf " $clone_dir "
191+ else
192+ echo " git clone fallback failed for ${repo} @${ref} " >&2
193+ return 1
194+ fi
195+ )
175196}
You can’t perform that action at this time.
0 commit comments