From 95758c77128261a671237fbb1ab5b007baa83821 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sun, 14 Apr 2019 13:12:56 -0700
Subject: [PATCH] Fix process for updating existing tags

svn lacks a rename/replace function, requiring first that an existing
tag be deleted before an update is copied into place. svn is, fortunately,
generally smart enough to sort out the history and show only the updated
files in the resulting commit.
---
 scripts/deploy.sh | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index b959309..b97421b 100644
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -92,13 +92,6 @@ cd "$SVN_DIR"
 # The --delete flag will delete anything in destination that no longer exists in source
 rsync -r "$TMP_DIR/" trunk/ --delete
 
-# If tag already exists, update from trunk.
-# Generally, this applies when bumping WP version compatibility.
-if [[ -d "$SVN_TAG_DIR" ]]; then
-    echo "➤ Updating existing tag..."
-    rsync -r trunk/ "$SVN_TAG_DIR" --delete
-fi
-
 # Copy dotorg assets to /assets
 rsync -r "${CI_PROJECT_DIR}/${WP_ORG_ASSETS_DIR}/" assets/ --delete
 
@@ -112,7 +105,15 @@ svn add . --force > /dev/null
 # Also suppress stdout here
 svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null
 
-# Copy new tag locally to make this a single commit
+# If tag already exists, remove and update from trunk.
+# Generally, this applies when bumping WP version compatibility.
+# svn doesn't have a proper rename function, prompting the remove/copy dance.
+if [[ -d "$SVN_TAG_DIR" ]]; then
+    echo "➤ Removing existing tag before update..."
+    svn rm "$SVN_TAG_DIR"
+fi
+
+# Copy new/updated tag to maintain svn history.
 if [[ ! -d "$SVN_TAG_DIR" ]]; then
     echo "➤ Copying tag..."
     svn cp "trunk" "$SVN_TAG_DIR"
-- 
GitLab