Skip to content

Commit 48e28ea

Browse files
Copilothuangyiirene
andcommitted
fix: improve pnpm-lock-autofix workflow logic based on code review
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent b4da9e2 commit 48e28ea

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/pnpm-lock-autofix.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,14 @@ jobs:
8787
CONFLICT_FILES=$(git diff --name-only --diff-filter=U)
8888
echo "Conflicted files: $CONFLICT_FILES"
8989
90-
if [ "$CONFLICT_FILES" = "pnpm-lock.yaml" ] || [ -z "$CONFLICT_FILES" ]; then
91-
echo "Only pnpm-lock.yaml has conflicts or no conflicts. Regenerating lockfile..."
90+
# Only proceed if pnpm-lock.yaml is the only conflicted file
91+
if [ "$CONFLICT_FILES" = "pnpm-lock.yaml" ]; then
92+
echo "Only pnpm-lock.yaml has conflicts. Regenerating lockfile..."
9293
9394
# Remove the conflicted lockfile
94-
git checkout --theirs pnpm-lock.yaml || git checkout --ours pnpm-lock.yaml || rm -f pnpm-lock.yaml
95+
# We remove it completely to let pnpm regenerate from package.json files
96+
# This ensures both branches' dependency changes are merged correctly
97+
rm -f pnpm-lock.yaml
9598
9699
# Regenerate the lockfile
97100
pnpm install --no-frozen-lockfile

0 commit comments

Comments
 (0)