Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

Configure Git merge drivers in CI workflows to automatically resolve pnpm-lock.yaml conflicts by regenerating the lockfile during merge operations.

Changes

  • All workflows (.github/workflows/test.yml, release.yml, deploy-docs.yml):
    • Configure custom Git merge driver after pnpm installation
    • Driver command: pnpm install --no-frozen-lockfile && test -f pnpm-lock.yaml && cp pnpm-lock.yaml %A || exit 1
    • Apply driver via .git/info/attributes (CI-only, no repository files modified)

How it works

When Git encounters a merge conflict in pnpm-lock.yaml:

  1. Driver regenerates lockfile from current package.json files
  2. Verifies lockfile exists
  3. Copies result to merge output location (%A)
  4. Merge continues automatically without manual intervention

This configuration only affects CI environments and does not modify repository files.

Original prompt

✅ 终极自动化方案(CI 脚本版)
不需要修改仓库里的任何文件,只需要在运行 git merge 之前加两行配置:

  • name: Auto Merge with Lockfile Fix
    run: |

    --- 步骤 1: 配置临时合并驱动 ---

    定义一个叫 pnpm-merge 的驱动,它的作用是运行 pnpm install

    git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
    git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"

    --- 步骤 2: 绑定策略 (关键) ---

    临时告诉 Git:对于 pnpm-lock.yaml 文件,使用上面定义的 pnpm-merge 驱动

    写入 .git/info/attributes 只对当前 CI 环境生效,不会弄脏您的代码仓库

    echo "pnpm-lock.yaml merge=pnpm-merge" >> .git/info/attributes

    --- 步骤 3: 像往常一样合并 ---

    此时,如果 lock 文件有冲突,Git 会在后台自动解决,不会报错

    git merge origin/main


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@hotlong hotlong marked this pull request as ready for review January 15, 2026 12:46
Copilot AI changed the title [WIP] Add auto merge with lockfile fix configuration Add automatic pnpm-lock.yaml merge conflict resolution in CI Jan 15, 2026
Copilot AI requested a review from huangyiirene January 15, 2026 13:02
@huangyiirene huangyiirene merged commit ec75335 into main Jan 17, 2026
1 check passed
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.

3 participants