From 193b763b8af606e8536e5c181df1de43cab7b1e2 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 22 Jul 2022 13:39:29 -0400
Subject: [PATCH] try to make the relevant refs available

---
 ci-tools/update-production | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/ci-tools/update-production b/ci-tools/update-production
index 1ed0a12e..3b2ab0f7 100755
--- a/ci-tools/update-production
+++ b/ci-tools/update-production
@@ -15,6 +15,11 @@ main() {
     local TARGET_BRANCH=$1
     shift
 
+    # Make sure the things we want to talk about are locally known.  GitLab
+    # seems to prefer to know about as few refs as possible.
+    checkout_git_ref "$SOURCE_BRANCH"
+    checkout_git_ref "$TARGET_BRANCH"
+
     # If there have been no changes we'll just abandon this update.
     if ! ensure_changes "$SOURCE_BRANCH" "$TARGET_BRANCH"; then
 	echo "No changes."
@@ -26,6 +31,13 @@ main() {
     create_merge_request "$TOKEN" "$SERVER_URL" "$PROJECT_ID" "$SOURCE_BRANCH" "$TARGET_BRANCH" "$NOTES"
 }
 
+checkout_git_ref() {
+    local REF=$1
+    shift
+
+    git fetch origin "$REF"
+}
+
 ensure_changes() {
     local SOURCE_BRANCH=$1
     shift
-- 
GitLab