fix(sync): cherry-pick upstream PRs instead of merging their branches
What
The upstream PR sync was merging each ionic-team/capacitor PR branch into plus. Those branches are based on upstream main, so the merge replayed every upstream commit that plus does not already have as a git ancestor. On conflicts it used -X theirs, which overwrote Capacitor+ files.
That is why open sync PRs showed 48 to 55 files when the upstream PRs only touched 1 to 7 files. The extra files were Capacitor+ customizations being reverted: CI, changelogs, package versions, SystemBars, HTTP interceptor tests, telemetry, CLI helpers, iOS scene handling, and more.
#231 later ported upstream file contents into plus, but it was squash-merged, so git still does not treat upstream main as an ancestor of plus. A later merge of an upstream PR branch still tries to replay those 53 upstream commits and then wipes plus files on conflicts.
How this fixes it
The scheduled workflows already source .github/scripts/sync-gh-helpers.sh. This PR updates that helper so:
git merge upstream-pr-Ncherry-picks only the commits that belong to that upstream PRgit merge upstream/main -X theirson plus (or a plus sync branch) keeps Capacitor+ hunks and still takes non-overlapping upstream changesmerge_upstream_preferreddoes the same plus-preserving path when the current branch is plus- The daily "already up to date" check treats a
cherry picked from committrailer as applied, because cherry-pick creates new SHAs - Repo-wide behavior of the YAML files is unchanged in text (pushing workflow files needs the GitHub
workflowscope, which the available tokens do not have). The sourced helper intercepts the harmfulgit mergecalls.
The main-branch mirror sync still prefers upstream, which is correct because main should match Capacitor.
Tests
bash .github/scripts/test-sync-gh-helpers.sh passes 9/9, including a test that reproduces the old wipe and a test that git merge upstream-pr-1 now changes only the upstream PR file.
Notes
- No new secrets. Still uses
PERSONAL_ACCESS_TOKEN. - No GitHub Actions pin or timeout changes (workflow YAML was left untouched).
- This PR targets
plus, the default branch the generator runs from.maintracks upstream Capacitor.
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by CodeRabbit
- Improvements
- Upstream updates now better preserve existing custom changes while incorporating upstream changes.
- Applying upstream pull request updates avoids bringing in unrelated changes from the upstream main branch.
- Conflicting changes can be resolved in favor of upstream where needed.