Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-changed-files fails with missing merge base #11271

Closed
jdanil opened this issue Apr 4, 2021 · 6 comments
Closed

jest-changed-files fails with missing merge base #11271

jdanil opened this issue Apr 4, 2021 · 6 comments

Comments

@jdanil
Copy link

jdanil commented Apr 4, 2021

💥 Regression Report

When an environment does not have the full commit history, running jest with the --changedSince option fails with an error.

A repository may find itself in this state when checking out a single commit rather than cloning the whole repo and history.

The regression was introduced in #10155.

Last working version

Worked up to version: 26.1.0

Stopped working in version: 26.2.0

To Reproduce

Steps to reproduce the behavior:

  1. Checkout a single commit from a feature branch.
  2. Run jest --changedSince=master

Expected behavior

jest-changed-files should detect changed files without erroring with a non-zero exit code.

Link to repl or repo (highly encouraged)

https://github.com/jdanil/jest-changed-files-repro

Logs from CI for any pull request.

yarn run v1.22.5
$ yarn test:ci --changedSince="master"
$ yarn test --ci --changedSince=master
$ jest --ci --changedSince=master


  ● Test suite failed to run

    fatal: master...HEAD: no merge base

Error: Process completed with exit code 1.

Run npx envinfo --preset jest

Paste the results here:

System:
  OS: Windows 10 10.0.18363
  CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
  Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 2.4.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
@jdanil jdanil changed the title jest-changed-files fails with detached HEAD jest-changed-files fails with missing merge base Apr 4, 2021
@jdanil
Copy link
Author

jdanil commented Apr 4, 2021

Updated the description after debugging a bit more. The issue seems to be due to a missing merge base rather than being in a detached HEAD state.

@SimenB
Copy link
Member

SimenB commented Apr 4, 2021

It sorta makes sense to me to fail in this case as the commit is missing. What should the behaviour be? We should not just ignore the flag as we wanna pick up typos (I think). Should we just document you need some other fetch depth for the flag to work?

I guess we could print a warning if we cannot resolve the base and just run all tests

@jdanil
Copy link
Author

jdanil commented Apr 4, 2021

Hey @SimenB, thanks for reviewing this issue so quickly.

I think even if the merge base is missing, if we have another branch to compare against, we can still run a diff on it. I was experimenting with running something like git diff --name-only ${changedSince} rather than git diff --name-only ${changedSince}...HEAD which seems to work in this case for me. When I ran the e2e tests though, I found that this script was catching two extra files as "changed" even though they were modified on the master branch only (the last expectation in this test case gets changed files for git).

Even if it would be preferred to not modify the current git diff command, I'm wondering whether it would be possible to put a try-catch around it and fall back to the proposed command or previous git log command in cases where there is a missing merge base?

@github-actions
Copy link

github-actions bot commented Apr 4, 2022

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Apr 4, 2022
@github-actions
Copy link

github-actions bot commented May 4, 2022

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as completed May 4, 2022
@github-actions
Copy link

github-actions bot commented Jun 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants