"update-dev" target (#40)

OVERRIDE now defaults to 1 for "update" and 0 for "update-dev".
This commit is contained in:
Ștefan Talpalaru 2022-01-26 15:20:55 +01:00 committed by GitHub
parent f62fa395f7
commit 8425ff9e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -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