Add option for rate limiting repo updates.
authorDaniel Abrecht <public@danielabrecht.ch>
Wed, 18 May 2022 19:55:08 +0000 (19:55 +0000)
committerDaniel Abrecht <public@danielabrecht.ch>
Wed, 18 May 2022 19:55:08 +0000 (19:55 +0000)
src/make-helper-functions.mk

index ca2d840afef78b1c926764af6f87ae2ee929f7c4..8547d739b849093d613c86dde5a4c0ea34d78625 100644 (file)
@@ -136,7 +136,10 @@ clean-repo//%:
 
 update-repo//%:
        repo="$(call repodir,$(patsubst update-repo//%,%,$@))"; \
-       if [ -d "$$repo" ]; then cd "$$repo" && git remote update && touch .; fi
+       if [ -d "$$repo" ] && ([ -z "$$UPDATE_REPO_ONLY_IF_OLDER_THAN" ] || [ "$$(($$(date '+%s') - $$(stat -c '%Y' "$$repo")))" -ge "$$UPDATE_REPO_ONLY_IF_OLDER_THAN" ]); \
+       then \
+         cd "$$repo" && git remote update && touch .; \
+       fi
 
 config-list:
        @$(foreach VAR,$(CONFIG_VARS), echo "$(VAR)" = "$($(VAR))"; )