Skip to content

fix: remove head branch fetch and checkout that fails on dirty worktree#6

Open
andrmoel wants to merge 1 commit into
mainfrom
devin/1780059436-fix-dirty-worktree-checkout
Open

fix: remove head branch fetch and checkout that fails on dirty worktree#6
andrmoel wants to merge 1 commit into
mainfrom
devin/1780059436-fix-dirty-worktree-checkout

Conversation

@andrmoel

Copy link
Copy Markdown

Summary

Removes the git fetch origin <head-ref> and git checkout <head-sha> commands from the "Fetch base branch for comparison" step.

Problem: When a consuming workflow runs yarn install (or similar) before this action, yarn.lock gets modified. The subsequent git checkout of the PR head SHA fails because git refuses to overwrite the dirty file:

error: Your local changes to the following files would be overwritten by checkout:
    yarn.lock
Please commit your changes or stash them before you switch branches.

This has been breaking the "Check test coverage" job on every PR in candidate-backend since the Node 24 upgrade (April 2026), because Node 24's yarn now modifies yarn.lock during install on merge commits.

Why the checkout is unnecessary: actions/checkout@v4 on pull_request events checks out a merge commit that already contains the PR's changes on top of the base branch. diff-cover --compare-branch=origin/master therefore produces the correct diff without needing to switch to the PR head commit.

A previous attempt to fix this with git checkout -f (commit 906d4b1) was merged and reverted within 17 minutes.

Review & Testing Checklist for Human

  • Merge this PR, then re-run the "Check test coverage" job on an open candidate-backend PR (e.g. #5339) to verify it passes
  • Verify the coverage report comment is correctly posted on the PR

Notes

The only remaining git command in the step is git fetch origin <base-ref>, which is needed so diff-cover can compare against origin/master.

Link to Devin session: https://app.devin.ai/sessions/91f6c3e0d63549379d22705dda69e5fd
Requested by: @andrmoel

When a consuming workflow runs yarn install before this action,
yarn.lock may be modified. The subsequent git checkout of the PR
head SHA fails because git refuses to overwrite the dirty file.

The checkout is unnecessary: actions/checkout@v4 on pull_request
events checks out a merge commit that already contains the PR
changes on top of the base branch, so diff-cover produces the
correct diff without switching commits.
@devin-ai-integration

Copy link
Copy Markdown
Contributor
Original prompt from moeller

Since a while the github action "check test coverage on new" is broken in our PRs.
Here is an example: https://github.com/doctariDev/candidate-backend/pull/5339
And here is another example: https://github.com/doctariDev/candidate-backend/actions/runs/26630467849/job/78477725330?pr=5341

Figure out what is causing the problem and explain it to me.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant