Skip to content

Commit 40de955

Browse files
committed
refactor: Improve docker_pull_check output handling
- Modified the docker_pull_check function to suppress the default "pull ran recently" message unless SPIN_DEBUG is set to true, enhancing the clarity of everyday output. - Ensured that the output variable is only echoed when necessary, streamlining the function's behavior.
1 parent 6835983 commit 40de955

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/functions.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ display_repository_metadata() {
226226

227227
docker_pull_check() {
228228
local pull=0
229-
local output=$(printf '%s\n' "${BOLD}${BLUE}[spin] ⚡️ Skipping docker image pull because it ran earlier.${RESET}")
229+
local output=""
230230

231231
for arg in "$@"; do
232232
case "$arg" in
@@ -240,11 +240,17 @@ docker_pull_check() {
240240
;;
241241
esac
242242
done
243-
243+
244+
# Default "pull ran recently" message is only useful when debugging why an image didn't refresh,
245+
# so hide it unless SPIN_DEBUG=true to keep everyday output quiet.
246+
if [ "$pull" == "0" ] && [ "${SPIN_DEBUG:-false}" == "true" ]; then
247+
output=$(printf '%s\n' "${BOLD}${BLUE}[spin] ⚡️ Skipping docker image pull because it ran earlier.${RESET}")
248+
fi
249+
244250
if [ "$pull" != "1" ] && (needs_update ".spin-last-pull" "$AUTO_PULL_INTERVAL_IN_DAYS" || [ "$pull" == "2" ]); then
245251
$COMPOSE_CMD pull
246252
update_last_pull_timestamp
247-
else
253+
elif [ -n "$output" ]; then
248254
echo "$output"
249255
fi
250256
}

0 commit comments

Comments
 (0)