Skip to content

Conversation

Copy link

Copilot AI commented Aug 23, 2025

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:

Auto-merging fastlane/Fastfile
CONFLICT (content): Merge conflict in fastlane/Fastfile
Automatic merge failed; fix conflicts and then commit the result.
ERROR: exit 1
New commits could not be pulled.

Root Cause

The sync script in Scripts/sync_with_upstream.sh had flawed conflict resolution logic for submodules. When Git encountered submodule conflicts (like G7SensorKit, LibreTransmitter, etc.), the script attempted to use git checkout --theirs on 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:

if git ls-files -s "$file" | grep -q "^160000"; then
    # This is a submodule - handle specially

Proper Submodule Resolution

Instead of failing checkout operations, the script now resolves submodule conflicts by:

  1. Getting the upstream commit hash for the submodule
  2. Using git update-index --cacheinfo to set the correct commit directly in the index
UPSTREAM_COMMIT=$(git ls-tree "upstream/$UPSTREAM_BRANCH" "$file" | awk '{print $3}')
git update-index --add --cacheinfo 160000 "$UPSTREAM_COMMIT" "$file"

Comprehensive Conflict Handling

The script now handles all common conflict scenarios:

  • Fastlane files (fastlane/Fastfile) → takes upstream version
  • Workflow files (.github/workflows/*) → takes upstream version
  • Dependencies (Gemfile, Gemfile.lock) → takes upstream version
  • Submodules (G7SensorKit, LibreTransmitter, OmniBLE, OmniKit) → takes upstream commits
  • Config files (VersionOverride.xcconfig) → takes upstream version
  • Workspace files (*.xcworkspacedata) → takes upstream version

Testing

The fix has been thoroughly tested with actual conflict scenarios. The script now successfully:

✅ Detects and resolves the fastlane/Fastfile conflict 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.

Copilot AI changed the title [WIP] @abmeks/LoopWorkspace/pull/3 there is still an issue here branch main -> FETCH_HEAD Auto-merging .github/workflows/build_loop.yml Auto-merging fastlane/Fastfile CONFLICT (content): Merge conflict in fastlane/Fastfile Automatic merge failed; fix conflic... Fix upstream sync script submodule conflict resolution Aug 23, 2025
Copilot AI requested a review from abmeks August 23, 2025 01:15
Copilot finished work on behalf of abmeks August 23, 2025 01:15
@abmeks abmeks marked this pull request as ready for review August 23, 2025 01:17
@abmeks abmeks merged commit 1df3cbf into main Aug 23, 2025
@abmeks abmeks deleted the copilot/fix-8593cb03-167b-4e6b-a15a-f1d99eb30660 branch August 23, 2025 01:18
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.

2 participants