Revision 385079bea7eaa4ee5d7abbe03c4ccb695516b5e8 authored by Christopher Moyer on 13 October 2022, 20:57:58 UTC, committed by GitHub on 13 October 2022, 20:57:58 UTC
* renames directory

* fixes relrefs
1 parent c137cf6
Raw File
clean-git-or-error.sh
#!/bin/bash
set -e

# Checks that a git working tree is clean. Exit 0 if it is, or exit 1 with a list of
# dirty files - including modifications, removals, and untracked+unignored files.

# Primarily intended for ensuring in CI that codegen operations are a no-op/have
# already been performed.

STAT="$(git status --porcelain 2>/dev/null)"
if [ -z "$STAT" ]
then
    exit 0
else
    echo "$STAT"
    exit 1
fi

# For safekeeping, alternative commands that meet a similar goal (in case the
# above approach ends up being problematic)
# 
# List modified/removed files and exit nonzero if any exist:
# git diff --stat --exit-code
#
# List untracked files, and exit nonzero if any exist:
# git ls-files --others --exclude-standard',
# u="$(git ls-files --others --exclude-standard)" && test -z "$u"
back to top