From c825b2d988a3d621d5534f36b1522558996bcc68 Mon Sep 17 00:00:00 2001 From: Muhammad Danish <88161975+mdanish-kh@users.noreply.github.com> Date: Fri, 25 Apr 2025 18:54:23 +0500 Subject: [PATCH] Retry sync fork on failure --- src/WingetCreateCore/Common/GitHub.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/WingetCreateCore/Common/GitHub.cs b/src/WingetCreateCore/Common/GitHub.cs index 7ace29de..c9fca15d 100644 --- a/src/WingetCreateCore/Common/GitHub.cs +++ b/src/WingetCreateCore/Common/GitHub.cs @@ -336,26 +336,24 @@ private async Task SubmitPRAsync(string packageId, string version, var upstreamMasterSha = upstreamMaster.Object.Sha; Reference newBranch = null; - bool forkSyncAttempted = false; - try { var retryPolicy = Policy .Handle() .Or() + .Or() .WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(i)); await retryPolicy.ExecuteAsync(async () => { // Related issue: https://github.com/microsoft/winget-create/issues/282 // There is a known issue where a reference is unable to be created if the fork is behind by too many commits. - // Always attempt to sync fork during first execution in order to mitigate the possibility of this scenario occurring. + // Always attempt to sync fork in order to mitigate the possibility of this scenario occurring. // If the fork is behind by too many commits, syncing will also fail with a NotFoundException. // Updating the fork can fail if it is a non-fast forward update, but this should not be blocking as pull request submission can still proceed. // If creating a reference fails, that means syncing the fork also failed, therefore the user will need to manually sync their repo regardless. - if (!forkSyncAttempted && submitToFork) + if (submitToFork) { - forkSyncAttempted = true; await this.UpdateForkedRepoWithUpstreamCommits(repo); }