From 59e78e05604bf62b8ce00f77185d52217fa6fe5f Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 9 Sep 2024 22:05:42 +0200 Subject: [PATCH] merge-after-ci: unstash only if stashed --- pkgs/tea-create-pr/script.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/tea-create-pr/script.sh b/pkgs/tea-create-pr/script.sh index 97ee9c7af..6b767f5a1 100755 --- a/pkgs/tea-create-pr/script.sh +++ b/pkgs/tea-create-pr/script.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -euo pipefail +set -x remoteFork="${1:-origin}" remoteUpstream="${2:-upstream}" @@ -32,12 +33,21 @@ fi # run formatting on a clean working tree echo "stashing uncommitted changes to run treefmt" -git stash push +if ! git diff --quiet --cached --exit-code || ! git diff --quiet --exit-code; then + git stash push + pop() { + git stash pop + } +else + pop() { + : + } +fi if ! treefmt --fail-on-change --no-cache; then - git stash pop + pop exit 1 fi -git stash pop +pop upstream_url=$(git remote get-url "$remoteUpstream") set -x