Skip to content

Commit 85113cc

Browse files
committed
Add "git-prefetch" script to avoid errors like "fatal: Couldn't find remote ref refs/heads/centos-7armhfp"
1 parent 08dc5af commit 85113cc

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

.template-helpers/git-prefetch.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
repo="${1:-}"
5+
if [ -z "$repo" ]; then
6+
echo >&2 "usage: $0 repo"
7+
echo >&2 " ie: $0 hylang"
8+
exit 1
9+
fi
10+
11+
# if we haven't set BASHBREW_LIBRARY explicitly (like Jenkins does, for example), don't trust the local library
12+
if [ -z "${BASHBREW_LIBRARY:-}" ]; then
13+
repo="https://github.com/docker-library/official-images/raw/master/library/$repo"
14+
fi
15+
16+
: "${BASHBREW_CACHE:=$HOME/.cache/bashbrew}"
17+
export BASHBREW_CACHE
18+
19+
# see "generate-dockerfile-links-partial.tmpl" for where our arch-choosing complexity comes from
20+
templateHeader='{{- $archSpecific := getenv "ARCH_SPECIFIC_DOCS" -}}'
21+
templateArchVar='{{- $arch := $archSpecific | ternary arch ($e.HasArchitecture arch | ternary arch ($e.Architectures | first)) -}}'
22+
23+
tags="$(bashbrew list --uniq "$repo" | cut -d: -f2-)"
24+
tags=( $tags )
25+
toFetch=()
26+
for tag in "$tags"; do
27+
if ! bashbrew cat --format '
28+
'"$templateHeader"'
29+
{{- $e := $.TagEntry -}}
30+
'"$templateArchVar"'
31+
{{- if $e.HasArchitecture $arch -}}
32+
{{- $from := $.ArchDockerFrom $arch $e -}}
33+
{{- end -}}
34+
' "$repo:$tag" &> /dev/null; then
35+
toFetch+=( "$repo:$tag" )
36+
fi
37+
done
38+
39+
if [ "${#toFetch[@]}" -eq 0 ]; then
40+
exit 0
41+
fi
42+
43+
bashbrewFetchTemplate='
44+
'"$templateHeader"'
45+
{{- range $i, $e := $.Entries -}}
46+
'"$templateArchVar"'
47+
{{- if $e.HasArchitecture $arch -}}
48+
{{- join "/" "refs/tags" $arch $.RepoName ($e.Tags | first) -}}
49+
{{- ":" -}}
50+
{{- "\n" -}}
51+
{{- end -}}
52+
{{- end -}}
53+
'
54+
55+
bashbrew cat --format "$bashbrewFetchTemplate" "$repo" \
56+
| xargs --no-run-if-empty git -C "$BASHBREW_CACHE/git" fetch --quiet --no-tags https://github.com/docker-library/commit-warehouse.git

update.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ for image in "${images[@]}"; do
110110
deprecated+=$'\n\n'
111111
fi
112112

113+
echo ' GIT PREFETCH => "'"$repo"'"'
114+
"$helperDir/git-prefetch.sh" "$repo"
115+
113116
targetFile="$repo/README.md"
114117

115118
{

0 commit comments

Comments
 (0)