Skip to content

Commit df6d544

Browse files
Copilothuangyiirene
andcommitted
Changes before error encountered
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 0fc976c commit df6d544

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

.github/WORKFLOWS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,67 @@ Add these badges to show workflow status:
338338
3. Update documentation
339339
4. Monitor first few runs after changes
340340

341+
## Automatic Lockfile Merge Resolution
342+
343+
### Overview
344+
345+
The repository is configured to automatically resolve merge conflicts in `pnpm-lock.yaml` using a custom Git merge driver. This prevents manual intervention when lockfile conflicts occur during branch merges or automated workflows.
346+
347+
### How It Works
348+
349+
**Repository Configuration** (`.gitattributes`):
350+
```
351+
pnpm-lock.yaml merge=pnpm-merge
352+
```
353+
354+
This tells Git to use the `pnpm-merge` driver when merging `pnpm-lock.yaml` files.
355+
356+
**Workflow Configuration** (Applied in CI workflows):
357+
```yaml
358+
- name: Configure Git merge driver for pnpm-lock.yaml
359+
run: |
360+
# Configure custom merge driver for pnpm-lock.yaml
361+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
362+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
363+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
364+
```
365+
366+
### When It's Used
367+
368+
This configuration is active in the following workflows:
369+
- **Changeset Release** (`changeset-release.yml`): Handles lockfile updates during version bumping
370+
- **Auto Changelog** (`changelog.yml`): Prevents conflicts during automated changelog updates
371+
372+
### Adding to New Workflows
373+
374+
If you create a workflow that performs git merge operations or might encounter lockfile conflicts, add the configuration step **after checkout** and **before any merge operation**:
375+
376+
```yaml
377+
steps:
378+
- name: Checkout code
379+
uses: actions/checkout@v4
380+
with:
381+
fetch-depth: 0
382+
383+
- name: Configure Git merge driver for pnpm-lock.yaml
384+
run: |
385+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
386+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
387+
388+
# ... rest of your workflow steps including merge operations
389+
```
390+
391+
### Benefits
392+
393+
- **Fully Automated**: No manual intervention needed for lockfile conflicts
394+
- **Clean Repository**: Configuration is temporary (CI-only), doesn't modify repository files
395+
- **Reliable**: Uses pnpm's built-in dependency resolution to regenerate lockfiles
396+
- **Consistent**: Ensures lockfiles are always in sync with package.json changes
397+
398+
### Local Development
399+
400+
For local development, contributors can configure the same merge driver by following the instructions in [CONTRIBUTING.md](../CONTRIBUTING.md).
401+
341402
## Future Enhancements
342403

343404
Potential workflow additions:

.github/workflows/changelog.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ jobs:
1818
with:
1919
fetch-depth: 0
2020

21+
- name: Configure Git merge driver for pnpm-lock.yaml
22+
run: |
23+
# Configure custom merge driver for pnpm-lock.yaml
24+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
25+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
26+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
27+
2128
- name: Generate changelog
2229
uses: orhun/git-cliff-action@v4
2330
id: changelog

.github/workflows/changeset-release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ jobs:
3434
cache: 'pnpm'
3535
registry-url: 'https://registry.npmjs.org'
3636

37+
- name: Configure Git merge driver for pnpm-lock.yaml
38+
run: |
39+
# Configure custom merge driver for pnpm-lock.yaml
40+
# This allows Git to automatically resolve lockfile conflicts by regenerating it
41+
git config merge.pnpm-merge.name "pnpm-lock.yaml merge driver"
42+
git config merge.pnpm-merge.driver "pnpm install --no-frozen-lockfile"
43+
3744
- name: Install dependencies
3845
run: pnpm install --frozen-lockfile
3946

0 commit comments

Comments
 (0)