Fix upstream sync script submodule conflict resolution #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The upstream sync process was failing with merge conflicts, specifically when encountering submodule conflicts during the merge with
LoopKit/LoopWorkspace. The error manifested as:Root Cause
The sync script in
Scripts/sync_with_upstream.shhad flawed conflict resolution logic for submodules. When Git encountered submodule conflicts (likeG7SensorKit,LibreTransmitter, etc.), the script attempted to usegit checkout --theirson them, which fails because submodules aren't regular files and can't be checked out when they're in an uninitialized conflict state.Solution
Enhanced Submodule Detection
The script now properly identifies submodules using their Git index mode (
160000) instead of relying on directory checks:Proper Submodule Resolution
Instead of failing checkout operations, the script now resolves submodule conflicts by:
git update-index --cacheinfoto set the correct commit directly in the indexComprehensive Conflict Handling
The script now handles all common conflict scenarios:
fastlane/Fastfile) → takes upstream version.github/workflows/*) → takes upstream versionGemfile,Gemfile.lock) → takes upstream versionG7SensorKit,LibreTransmitter,OmniBLE,OmniKit) → takes upstream commitsVersionOverride.xcconfig) → takes upstream version*.xcworkspacedata) → takes upstream versionTesting
The fix has been thoroughly tested with actual conflict scenarios. The script now successfully:
✅ Detects and resolves the
fastlane/Fastfileconflict mentioned in the issue✅ Handles multiple submodule conflicts automatically
✅ Completes the merge process without manual intervention
✅ Exits with success code instead of failing
Impact
This fix ensures that the automated upstream sync process will continue working reliably even when there are merge conflicts, keeping the fork in sync with the latest LoopKit improvements without requiring manual intervention.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.