From: Prarit Bhargava <pra...@redhat.com>

redhat/Makefile: add dist-assert-tree-clean target

Add dist-assert-tree-clean target that fails whenever staged/unstaged
changes or untracked files are present in the git tree.

Manual invocation of this target is not expected, thus left out of
dist-help. It's intended to act as a guard against any temporary changes
prior to running tooling that could change or revert them.

No checks are performed whenever $FORCE is non-empty.

Signed-off-by: Čestmír Kalina <ckal...@redhat.com>
Signed-off-by: Prarit Bhargava <pra...@redhat.com>

diff --git a/redhat/Makefile b/redhat/Makefile
index blahblah..blahblah 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -331,6 +331,25 @@ dist-kabi-dup: dist-python-check
                fi \
        done;
 
+dist-assert-tree-clean:
+ifeq ($(FORCE),)
+       @if ! git diff-index --quiet --cached HEAD -- &> /dev/null; then \
+               echo "ERROR: staged changes found. Please clean the git tree."; 
>&2 \
+               git status; \
+               exit 1; \
+       fi
+       @if ! git diff-files --quiet &> /dev/null; then \
+               echo "ERROR: unstaged changes found. Please clean the git 
tree." >&2; \
+               git status; \
+               exit 1; \
+       fi
+       @if [ $$(git ls-files --exclude-standard --others | wc -l) -gt 0 ]; 
then \
+               echo "ERROR: untracked files found. Please clean the git tree." 
>&2; \
+               git status; \
+               exit 1; \
+       fi
+endif
+
 dist-check-kabi: dist-kabi
        @if [ ! -e $(_OUTPUT)/Module.symvers ]; then \
                echo "ERROR: You must compile the kernel and modules first";\

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/2021
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to