From ca79c2b9e87eb17746821fdd2eb8390b2886cd45 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 23 Aug 2025 00:44:05 +0000 Subject: [PATCH 1/3] Initial plan From c0ee6137a984912be7af7028ba733df75fa4713b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 00:49:03 +0000 Subject: [PATCH 2/3] Fix upstream sync workflow logic to handle merge conflicts properly Co-authored-by: abmeks <162530445+abmeks@users.noreply.github.com> --- .github/workflows/build_loop.yml | 41 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_loop.yml b/.github/workflows/build_loop.yml index 2a9755efa6..52d1fccae1 100644 --- a/.github/workflows/build_loop.yml +++ b/.github/workflows/build_loop.yml @@ -233,26 +233,43 @@ jobs: vars.SCHEDULED_SYNC != 'false' && github.repository_owner != 'LoopKit' && needs.check_latest_from_upstream.outputs.ABORT_SYNC == 'false' id: sync run: | - # First try the standard fork sync action - set +e - echo "Attempting standard fork sync..." + set -e + echo "Starting upstream sync process..." - # Use the fork sync action first - gh extension install aormsby/gh-fork-sync || echo "Extension already installed" + # Try to install gh-fork-sync extension if not already installed + if ! gh extension list | grep -q "aormsby/gh-fork-sync"; then + echo "Installing gh-fork-sync extension..." + gh extension install aormsby/gh-fork-sync || echo "Failed to install extension" + fi - # Try fork sync with the action approach first - sync_result=0 + # Try gh-fork-sync first if available + if gh extension list | grep -q "aormsby/gh-fork-sync"; then + echo "Using gh-fork-sync extension..." + set +e + gh fork-sync --upstream "$UPSTREAM_REPO" --branch "$TARGET_BRANCH" + sync_result=$? + set -e + + if [ $sync_result -eq 0 ]; then + echo "Fork sync completed successfully" + echo "has_new_commits=true" >> $GITHUB_OUTPUT + exit 0 + else + echo "Fork sync failed, falling back to custom script..." + fi + else + echo "gh-fork-sync not available, using custom script..." + fi - # If the action approach fails, use our custom script - echo "Using custom sync script to handle potential conflicts..." + # Use our custom script as fallback or primary method + echo "Using custom sync script to handle merge conflicts..." bash ./Scripts/sync_with_upstream.sh sync_result=$? if [ $sync_result -eq 0 ]; then - echo "Sync completed successfully" - echo "has_new_commits=true" >> $GITHUB_OUTPUT + echo "Custom sync completed successfully" else - echo "Sync failed" + echo "Custom sync failed" exit 1 fi env: From 224dd61e8ca565a66b5c83dbabd4c8e768ed5c41 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 00:56:03 +0000 Subject: [PATCH 3/3] Complete sync script improvements for merge conflict resolution Co-authored-by: abmeks <162530445+abmeks@users.noreply.github.com> --- Scripts/sync_with_upstream.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Scripts/sync_with_upstream.sh b/Scripts/sync_with_upstream.sh index a4f08d81a8..fd4dca9bf5 100755 --- a/Scripts/sync_with_upstream.sh +++ b/Scripts/sync_with_upstream.sh @@ -71,10 +71,14 @@ fi # Attempt merge with upstream echo -e "${YELLOW}Attempting to merge upstream changes${NC}" -if git merge "upstream/$UPSTREAM_BRANCH" --no-edit; then +if git merge "upstream/$UPSTREAM_BRANCH" --no-edit --allow-unrelated-histories; then echo -e "${GREEN}Successfully merged upstream changes without conflicts${NC}" echo -e "${GREEN}Pushing changes to origin${NC}" - git push origin "$TARGET_BRANCH" + if [ "$GH_PAT" = "dummy" ]; then + echo -e "${YELLOW}Skipping push (dummy PAT provided)${NC}" + else + git push origin "$TARGET_BRANCH" + fi exit 0 fi