From 7f0828c84388a67dcfbcfe438f5a4ecf32a4a2c1 Mon Sep 17 00:00:00 2001 From: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com> Date: Sun, 6 Sep 2026 16:37:14 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E4=B8=8A=E6=B5=81=E3=81=AE?= =?UTF-8?q?=E3=83=9E=E3=83=BC=E3=82=B8=E6=99=82=E3=81=AB=E4=B8=8A=E6=B5=81?= =?UTF-8?q?=E3=81=AE=E7=94=9F=E6=88=90=E7=89=A9=E3=82=92=E6=8E=A1=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/merge-upstream.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/merge-upstream.yml b/.github/workflows/merge-upstream.yml index 1f958a543..ebe1fad99 100644 --- a/.github/workflows/merge-upstream.yml +++ b/.github/workflows/merge-upstream.yml @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + with: + fetch-depth: 0 - name: Configure Git run: | @@ -38,8 +40,11 @@ jobs: - name: Attempt merge with commit markers run: | # Try to merge but allow conflicts - TARGET_COMMIT=$(git rev-parse ${{ github.event.inputs.upstream_ref }}) - git merge --no-commit --no-ff --allow-unrelated-histories $TARGET_COMMIT || true + TARGET_COMMIT=$(git rev-parse "${{ github.event.inputs.upstream_ref }}") + git merge --no-commit --no-ff "$TARGET_COMMIT" || { + # Continue only when the merge started and stopped because of conflicts. + test -f "$(git rev-parse --git-path MERGE_HEAD)" || exit 1 + } # Remove upstream `.github/` directory git checkout HEAD -- .github/ @@ -52,6 +57,22 @@ jobs: esac done + # Generated test references always follow upstream. + while IFS= read -r -d '' file; do + git checkout --theirs -- "$file" + git add -- "$file" + done < <(git diff --name-only --diff-filter=U -z -- tests/ref/) + + # Do not silently resolve non-text conflicts outside generated files. + while IFS= read -r -d '' file; do + if ! grep -q '^<<<<<<< ' "$file" \ + || ! grep -qx '=======' "$file" \ + || ! grep -q '^>>>>>>> ' "$file"; then + echo "::error file=$file::Unresolved conflict without conflict markers" + exit 1 + fi + done < <(git diff --name-only --diff-filter=U -z) + # Commit the merge with conflict markers git commit -a -m "Merge upstream changes from ${{ github.event.inputs.upstream_ref }}" From 9edec0aa7c1a5bca5e536bda8c94d73e1e34dafb Mon Sep 17 00:00:00 2001 From: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com> Date: Mon, 7 Sep 2026 00:09:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E4=B8=8A=E6=B5=81=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E5=8F=96=E5=BE=97=E3=81=A8=E7=AB=B6=E5=90=88?= =?UTF-8?q?=E6=A4=9C=E8=A8=BC=E3=82=92=E5=AE=89=E5=85=A8=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/merge-upstream.yml | 39 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/merge-upstream.yml b/.github/workflows/merge-upstream.yml index ebe1fad99..d3162a20c 100644 --- a/.github/workflows/merge-upstream.yml +++ b/.github/workflows/merge-upstream.yml @@ -15,6 +15,8 @@ permissions: jobs: merge-upstream: runs-on: ubuntu-24.04 + env: + UPSTREAM_REF: ${{ github.event.inputs.upstream_ref }} steps: - name: Checkout repository uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 @@ -30,17 +32,20 @@ jobs: - name: Create new branch run: | - git checkout -b feature/merge-upstream-${{ github.event.inputs.upstream_ref }} + git check-ref-format "refs/tags/$UPSTREAM_REF" + git checkout -b "feature/merge-upstream-$UPSTREAM_REF" - - name: Add upstream remote + - name: Fetch upstream tag run: | git remote add upstream https://github.com/typst/typst.git - git fetch upstream + git fetch --no-tags upstream \ + "refs/tags/$UPSTREAM_REF:refs/remotes/upstream-tags/$UPSTREAM_REF" - name: Attempt merge with commit markers run: | # Try to merge but allow conflicts - TARGET_COMMIT=$(git rev-parse "${{ github.event.inputs.upstream_ref }}") + TARGET_COMMIT=$(git rev-parse --verify \ + "refs/remotes/upstream-tags/$UPSTREAM_REF^{commit}") git merge --no-commit --no-ff "$TARGET_COMMIT" || { # Continue only when the merge started and stopped because of conflicts. test -f "$(git rev-parse --git-path MERGE_HEAD)" || exit 1 @@ -65,20 +70,30 @@ jobs: # Do not silently resolve non-text conflicts outside generated files. while IFS= read -r -d '' file; do - if ! grep -q '^<<<<<<< ' "$file" \ - || ! grep -qx '=======' "$file" \ - || ! grep -q '^>>>>>>> ' "$file"; then - echo "::error file=$file::Unresolved conflict without conflict markers" + if [[ ! -f "$file" ]]; then + echo "::error file=$file::Unresolved conflict is not a regular file" + exit 1 + fi + + if ! grep -Iq . -- "$file"; then + echo "::error file=$file::Unresolved binary conflict outside tests/ref/" + exit 1 + fi + + if ! grep -q '^<<<<<<< ' -- "$file" \ + || ! grep -qx '=======' -- "$file" \ + || ! grep -q '^>>>>>>> ' -- "$file"; then + echo "::error file=$file::Unresolved text conflict without conflict markers" exit 1 fi done < <(git diff --name-only --diff-filter=U -z) # Commit the merge with conflict markers - git commit -a -m "Merge upstream changes from ${{ github.event.inputs.upstream_ref }}" + git commit -a -m "Merge upstream changes from $UPSTREAM_REF" - name: Push branch run: | - git push --force origin feature/merge-upstream-${{ github.event.inputs.upstream_ref }} + git push --force origin "feature/merge-upstream-$UPSTREAM_REF" - name: Create Pull Request id: create-pr @@ -95,9 +110,9 @@ jobs: const pr = await github.rest.pulls.create({ owner: context.repo.owner, repo: context.repo.repo, - head: "feature/merge-upstream-${{ github.event.inputs.upstream_ref }}", + head: `feature/merge-upstream-${process.env.UPSTREAM_REF}`, base: "main", - title: "Merge upstream ${{ github.event.inputs.upstream_ref }}", + title: `Merge upstream ${process.env.UPSTREAM_REF}`, body: process.env.PR_BODY }); core.setOutput("pr_number", pr.data.number);