Add 'make reset' target with warning prompt to reset git repo and submodules (#1258)

This commit is contained in:
Joe LeVeque 2017-12-21 11:15:06 -08:00 committed by GitHub
parent c898a04b28
commit ee73cdec26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,7 +63,7 @@ SONIC_BUILD_INSTRUCTION := make \
USERNAME=$(USERNAME) \
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS)
.PHONY: sonic-slave-build sonic-slave-bash init
.PHONY: sonic-slave-build sonic-slave-bash init reset
.DEFAULT_GOAL := all
@ -98,5 +98,18 @@ sonic-slave-bash :
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash
init :
git submodule update --init --recursive
git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'
@git submodule update --init --recursive
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'
reset :
@echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
@read ans && \
if [ $$ans == y ]; then \
git clean -xfdf; \
git reset --hard; \
git submodule foreach --recursive git clean -xfdf; \
git submodule foreach --recursive git reset --hard; \
git submodule update --init --recursive;\
else \
echo "Reset aborted"; \
fi