From b7ae258f69610e6373bdbbd7341e16964d8e1c79 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:56:51 +0700 Subject: [PATCH] Refactor test-git-no-uncommitted-changes to independent script --- .github/workflows/ci-meson.yml | 2 +- Makefile | 8 +------- tools/test-git-no-uncommitted-changes | 10 ++++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100755 tools/test-git-no-uncommitted-changes diff --git a/.github/workflows/ci-meson.yml b/.github/workflows/ci-meson.yml index 13ae8d9dc92..edac659b006 100644 --- a/.github/workflows/ci-meson.yml +++ b/.github/workflows/ci-meson.yml @@ -79,7 +79,7 @@ jobs: id: check_update_meson run: | python3 tools/update-meson.py - make test-git-no-uncommitted-changes + ./tools/test-git-no-uncommitted-changes continue-on-error: true - name: Show files changed by update-meson diff --git a/Makefile b/Makefile index 15dbbb411c0..4b5e9350d3e 100644 --- a/Makefile +++ b/Makefile @@ -254,13 +254,7 @@ TEST_TARGET = $@ TEST = ./sage -t --logfile=$(TEST_LOG) $(TEST_FLAGS) --optional=$(TEST_OPTIONAL) $(TEST_FILES) test-git-no-uncommitted-changes: - @UNCOMMITTED=$$(git status --porcelain); \ - if [ -n "$$UNCOMMITTED" ]; then \ - echo "Error: the git repo has uncommitted changes:"; \ - echo "$$UNCOMMITTED"; \ - echo; \ - exit 1; \ - fi + ./tools/test-git-no-uncommitted-changes test: all @echo '### make $(TEST_TARGET): Running $(TEST)' >> $(TEST_LOG) diff --git a/tools/test-git-no-uncommitted-changes b/tools/test-git-no-uncommitted-changes new file mode 100755 index 00000000000..f79997062f5 --- /dev/null +++ b/tools/test-git-no-uncommitted-changes @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +# Test that there is no uncommitted changes in the repository. Return failure if there is. +# Can also be invoked with `make test-git-no-uncommitted-changes` from top level. +UNCOMMITTED="$(git status --porcelain)"; +if [ -n "$UNCOMMITTED" ]; then + echo "Error: the git repo has uncommitted changes:"; + echo "$UNCOMMITTED"; + echo; + exit 1; +fi