From 8425ff9e3b6adb83e226d408a5d06d31ac2a7789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Wed, 26 Jan 2022 15:20:55 +0100 Subject: [PATCH] "update-dev" target (#40) OVERRIDE now defaults to 1 for "update" and 0 for "update-dev". --- README.md | 13 +++++++++++++ makefiles/targets.mk | 6 +++++- makefiles/variables.mk | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f1f756..8662751 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,14 @@ EXCLUDED_NIM_PACKAGES := vendor/nim-waku/vendor/nim-chronos \ As you see, we can exclude all those "nim-dnsdisc" submodules with a single line, because the pattern is not anchored during the match. +### OVERRIDE + +Whether to override any uncommitted changes to Git submodules during `make +update`. Defaults to 1, in order to keep the old behaviour for users building +from source. + +Set to 0 inside `make update-dev`, to help developers avoid losing work. + ## Make targets ### build @@ -252,6 +260,11 @@ committed files. Tell your users to run `make update` after cloning the superproject, after a `git pull` and after changing branches or checking out older commits. +## update-dev + +Alternative to "update" for developers who want to avoid losing uncommitted +work in Git submodules. `make update-dev` simply runs `make OVERRIDE=0 update`. + ### update-remote Dangerous target that updates all submodules to their latest remote commit. diff --git a/makefiles/targets.mk b/makefiles/targets.mk index a652814..296cfc8 100644 --- a/makefiles/targets.mk +++ b/makefiles/targets.mk @@ -88,7 +88,7 @@ update-test: TEE_TO_TTY="cat"; if bash -c ": >/dev/tty" &>/dev/null; then TEE_TO_TTY="tee /dev/tty"; fi; \ COMMAND="git status --short --untracked-files=no --ignore-submodules=untracked"; \ LINES=$$({ $${COMMAND} | grep 'vendor' && echo ^---top level || true; git submodule foreach --recursive --quiet "$${COMMAND} | grep . && echo ^---\$$name || true"; } | $${TEE_TO_TTY} | wc -l); \ - if [[ "$${LINES}" -ne "0" && "$(OVERRIDE)" != "1" ]]; then echo -e "\nYou have uncommitted local changes which might be overwritten by the update. Aborting.\nIf you know better, you can re-run the command with OVERRIDE=1.\n"; exit 1; fi + if [[ "$${LINES}" -ne "0" && "$(OVERRIDE)" != "1" ]]; then echo -e "\nYou have uncommitted local changes which might be overwritten by the update. Aborting.\nIf you know better, you can use the 'update' target instead of 'update-dev'.\n"; exit 1; fi #- for each submodule, delete checked out files (that might prevent a fresh checkout); skip dotfiles #- in case of submodule URL changes, propagates that change in the parent repo's .git directory @@ -111,6 +111,10 @@ update-common: | sanity-checks update-test rm -rf $(NIMBLE_DIR) + "$(MAKE)" --no-print-directory deps-common +# supposed to be used by developers, instead of "update", to avoid losing submodule work +update-dev: + + "$(MAKE)" OVERRIDE=0 update + #- rebuilds the Nim compiler if the corresponding submodule is updated $(NIM_BINARY): | sanity-checks + "$(MAKE)" --no-print-directory build-nim diff --git a/makefiles/variables.mk b/makefiles/variables.mk index 933bb8f..c243cd4 100644 --- a/makefiles/variables.mk +++ b/makefiles/variables.mk @@ -116,3 +116,5 @@ USE_SYSTEM_NIM := 0 # Skip multiple bootstrap iterations and tool building. QUICK_AND_DIRTY_COMPILER := 0 +# Override local submodule changes during `make update`. On by default. Turned off in `make update-dev`. +OVERRIDE := 1