From 913e9e7c0a833cfe00cf38b1424e4efbca4fd0b0 Mon Sep 17 00:00:00 2001 From: y-yagi Date: Fri, 7 Oct 2022 11:45:15 +0900 Subject: [PATCH] chore: simplify an example of diff checking (#69) The original sample hides the result of `git diff`. So if `git diff` returns an error(e.g. invalid file name specified), the result will be success. We can use `--exit-code ` option if we only want to know whether differences exist without depending on other commands. Ref: https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---exit-code --- .github/workflows/check-dist.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index f1636d8..fb93e92 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -38,7 +38,7 @@ jobs: - name: Compare the expected and actual dist/ directories run: | - if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then + if ! git diff --ignore-space-at-eol --exit-code --quiet dist/; then echo "Detected uncommitted changes after build. See status below:" git diff exit 1 diff --git a/README.md b/README.md index 6133b8e..ca16718 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ steps: - name: Verify generated types match Postgres schema run: | supabase gen types typescript --local > schema.gen.ts - if [ "$(git diff --ignore-space-at-eol schema.gen.ts | wc -l)" -gt "0" ]; then + if ! git diff --ignore-space-at-eol --exit-code --quiet schema.gen.ts; then echo "Detected uncommitted changes after build. See status below:" git diff exit 1