From 86610439361fbaffb8f30f7c65e5dd05d8596dd8 Mon Sep 17 00:00:00 2001
From: aholstrup1 <aholstrup1@microsoft.com@users.noreply.github.com>
Date: Mon, 18 Mar 2024 10:05:35 +0100
Subject: [PATCH] Stash before continuing

---
 build/scripts/CrossBranchPorting.psm1 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/build/scripts/CrossBranchPorting.psm1 b/build/scripts/CrossBranchPorting.psm1
index 6e7be7f87b..8c318a92ec 100644
--- a/build/scripts/CrossBranchPorting.psm1
+++ b/build/scripts/CrossBranchPorting.psm1
@@ -118,7 +118,9 @@ function PrecheckBackport($TargetBranches, $PullRequestNumber) {
 
     # Check that there are no uncommitted changes
     if (RunAndCheck git diff --name-only) {
-        throw "You have uncommitted changes. Please commit, revert or stash your changes before running this command."
+        Write-Warning "You have uncommitted changes. Please commit, revert or stash your changes before running this command."
+        GetConfirmation -Message "Do you want to stash your changes and continue?"
+        RunAndCheck git stash
     }
 
     # Validate Target Branches exist