Skip to content

release-winget: sync winget-pkgs fork before submitting#883

Open
dscho wants to merge 1 commit intovfs-2.53.0from
update-winget-fork-if-necessary
Open

release-winget: sync winget-pkgs fork before submitting#883
dscho wants to merge 1 commit intovfs-2.53.0from
update-winget-fork-if-necessary

Conversation

@dscho
Copy link
Copy Markdown
Member

@dscho dscho commented Apr 17, 2026

The wingetcreate.exe submit command fails when the winget-pkgs fork is behind upstream, with The forked repository could not be synced with the upstream commits. This happened in https://github.com/microsoft/git/actions/runs/24558034627/job/71799343977 because dscho/winget-pkgs was 21,033 commits behind.

This adds a call to the GitHub REST API's merge-upstream endpoint before submit, which is the programmatic equivalent of clicking the 'Sync fork' / 'Update branch' button in the GitHub web UI.

A 404 (no fork yet) is tolerated, since wingetcreate will create a fresh fork in that case.

The `wingetcreate.exe submit` command uses a GitHub token to fork
microsoft/winget-pkgs (if needed) and open a PR with the new manifest.
When the fork already exists but is behind upstream, wingetcreate
fails with "The forked repository could not be synced with the
upstream commits. Sync your fork manually and try again." This
happened in
https://github.com/microsoft/git/actions/runs/24558034627/job/71799343977
because dscho/winget-pkgs was 21,033 commits behind upstream.

Fix this by calling the GitHub REST API's "sync a fork branch with
the upstream repository" endpoint before invoking `submit`:

    POST /repos/{owner}/{repo}/merge-upstream

(documented at
https://docs.github.com/en/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository)

This is the programmatic equivalent of clicking the "Sync fork" /
"Update branch" button in the GitHub web UI.

The sync call is wrapped in a try/catch that tolerates a 404
response, because on the very first run there may be no fork yet.
In that case `wingetcreate submit` will create the fork fresh (and
therefore up-to-date), so a 404 is harmless. Any other error is
re-thrown so the workflow still fails visibly.

Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Apr 17, 2026
@dscho dscho requested a review from mjcheetham April 17, 2026 10:03
@dscho
Copy link
Copy Markdown
Member Author

dscho commented Apr 17, 2026

Triggered by https://github.com/microsoft/git/actions/runs/24558034627/attempts/1 (which I re-ran after sync'ing my fork manually).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant