From 8771a4c49f23e941c3cdf446e44bd26a28e59b10 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 29 Dec 2015 15:36:36 -0800 Subject: [PATCH] Switch %%LOGO%% to use an explicit commit link so that logos update in the same way the rest of the content does --- update.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/update.sh b/update.sh index 7edaaa5e..e4a0b5f8 100755 --- a/update.sh +++ b/update.sh @@ -107,11 +107,21 @@ for repo in "${repos[@]}"; do fi logo= - if [ -e "$repo/logo.png" ]; then - logo="![logo](https://raw.githubusercontent.com/docker-library/docs/master/$repo/logo.png)" - elif [ -e "$repo/logo.svg" ]; then - # rawgit.com because: http://stackoverflow.com/a/16462143/433558 - logo="![logo](https://rawgit.com/docker-library/docs/master/$repo/logo.svg)" + logoFile= + for f in png svg; do + if [ -e "$repo/logo.$f" ]; then + logoFile="$repo/logo.$f" + break + fi + done + if [ "$logoFile" ]; then + logoCommit="$(git log -1 --format='format:%H' -- "$logoFile" 2>/dev/null || true)" + [ "$logoCommit" ] || logoCommit='master' + if [ "${logoFile##*.}" = 'svg' ]; then + logo="![logo](https://rawgit.com/docker-library/docs/$logoCommit/$logoFile)" + else + logo="![logo](https://raw.githubusercontent.com/docker-library/docs/$logoCommit/$logoFile)" + fi fi compose=