Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/WingetCreateCore/Common/GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,26 +336,24 @@ private async Task<PullRequest> SubmitPRAsync(string packageId, string version,
var upstreamMasterSha = upstreamMaster.Object.Sha;

Reference newBranch = null;
bool forkSyncAttempted = false;

try
{
var retryPolicy = Policy
.Handle<ApiException>()
.Or<NonFastForwardException>()
.Or<GenericSyncFailureException>()
.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);
}

Expand Down
Loading