From 8406e93718a05de4dad0d8c4ea47fcc81134d9c2 Mon Sep 17 00:00:00 2001 From: Eric Promislow Date: Fri, 22 Oct 2021 10:35:41 -0700 Subject: [PATCH] Do a second check when `git describe` finds changes Running `git status` in the .variables script shows 11 deleted files. I tried using `git update-index --assume-unchanged ` but got an error that you can't do that on a readonly file system. If it's a readonly file system I don't know how those files got deleted, but here's a kludgy workaround. Verify that `git status -s` reports only those 11 deleted files. If so, strip the '.m' suffix off the VERSION variable. Signed-off-by: Eric Promislow --- scripts/build/.variables | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scripts/build/.variables b/scripts/build/.variables index 9b7cad828be3..7383ad0e651b 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -5,6 +5,38 @@ TARGET=${TARGET:-"build"} PLATFORM=${PLATFORM:-} VERSION=${VERSION:-$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags | sed 's/^v//' 2>/dev/null || echo "unknown-version" )} +case "$VERSION" in + *.m) if git status -s | awk 'BEGIN { +a[".circleci/config.yml"] = 0 +a[".dockerignore"] = 0 +a[".github/CODEOWNERS"] = 0 +a[".github/ISSUE_TEMPLATE.md"] = 0 +a[".github/PULL_REQUEST_TEMPLATE.md"] = 0 +a[".github/workflows/build.yml"] = 0 +a[".github/workflows/codeql-analysis.yml"] = 0 +a[".github/workflows/validate.yml"] = 0 +a[".gitignore"] = 0 +a["appveyor.yml"] = 0 +a["cli/winresources/winresources.go"] = 0 +expectedLen = length(a); +} +$1 == "D" || $1 == "M" || $1 == "??" { a[$2] = 1 } +END { + foundLen = length(a); + if (expectedLen != foundLen) { + exit(1); + } + for (key in a) { + if (a[key] == 0) { + exit(1); + } + } +}' ; then + VERSION=${VERSION%.m} +fi + ;; +esac + GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)} BUILDTIME=${BUILDTIME:-$(date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}