From 91487a0b23dd419bd0bd06fb200fb3230cbe4c61 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 15 Jul 2025 11:23:34 +0200 Subject: [PATCH] chore: fix login sync (#10250) # Which Problems Are Solved When changes are pulled or pushed from or to a login repository, they can't be merged to zitadel, because the commit histories differ. # How the Problems Are Solved Changed the commands to allow diverging commit histories. Pulling takes a lot of commits into the zitadel repo branch like this. This is fine, as we anyway squash-merge PRs to a single commit. So we don't care about a branches commit history. # Additional Changes Added an exception to the close-pr.yml workflow so sync PRs are not auto-closed. --------- Signed-off-by: dependabot[bot] Co-authored-by: Florian Forster Co-authored-by: Max Peintner Co-authored-by: Max Peintner Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 15 +++++++++++---- login/.github/workflows/close_pr.yml | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b2d6e508dd..2d70809a74 100644 --- a/Makefile +++ b/Makefile @@ -180,18 +180,25 @@ core_lint: .PHONY: login_pull login_pull: login_ensure_remote @echo "Pulling changes from the 'login' subtree on remote $(LOGIN_REMOTE_NAME) branch $(LOGIN_REMOTE_BRANCH)" - git fetch $(LOGIN_REMOTE_NAME) - git subtree pull --prefix=login $(LOGIN_REMOTE_NAME) $(LOGIN_REMOTE_BRANCH) + git fetch $(LOGIN_REMOTE_NAME) $(LOGIN_REMOTE_BRANCH) + git merge -s ours --allow-unrelated-histories $(LOGIN_REMOTE_NAME)/$(LOGIN_REMOTE_BRANCH) -m "Synthetic merge to align histories" + git push .PHONY: login_push login_push: login_ensure_remote @echo "Pushing changes to the 'login' subtree on remote $(LOGIN_REMOTE_NAME) branch $(LOGIN_REMOTE_BRANCH)" - git subtree push --prefix=login $(LOGIN_REMOTE_NAME) $(LOGIN_REMOTE_BRANCH) + git subtree split --prefix=login -b login-sync-tmp + git checkout login-sync-tmp + git fetch $(LOGIN_REMOTE_NAME) main + git merge -s ours --allow-unrelated-histories $(LOGIN_REMOTE_NAME)/main -m "Synthetic merge to align histories" + git push $(LOGIN_REMOTE_NAME) login-sync-tmp:$(LOGIN_REMOTE_BRANCH) + git checkout - + git branch -D login-sync-tmp login_ensure_remote: @if ! git remote get-url $(LOGIN_REMOTE_NAME) > /dev/null 2>&1; then \ echo "Adding remote $(LOGIN_REMOTE_NAME)"; \ - git remote add --fetch $(LOGIN_REMOTE_NAME) $(LOGIN_REMOTE_URL); \ + git remote add $(LOGIN_REMOTE_NAME) $(LOGIN_REMOTE_URL); \ else \ echo "Remote $(LOGIN_REMOTE_NAME) already exists."; \ fi diff --git a/login/.github/workflows/close_pr.yml b/login/.github/workflows/close_pr.yml index 6029e36d4c..90f92eff55 100644 --- a/login/.github/workflows/close_pr.yml +++ b/login/.github/workflows/close_pr.yml @@ -8,7 +8,7 @@ on: jobs: auto-close: runs-on: ubuntu-latest - if: github.repository_id == '622995060' + if: github.repository_id == '622995060' && github.ref_name != 'mirror-zitadel-repo' steps: - name: Comment and close PR uses: actions/github-script@v7