🐛 BUG: Tests fail if old version of git installed on system
See original GitHub issueWhat version of Wrangler
are you using?
2.0.29
What operating system are you using?
Windows (WSL)
Describe the Bug
The tests for wrangler init expect the default branch to be main, and hence fail if it is not. To set the default branch to main, we use the flag --initial-branch
but this only exists from git version 2.28. If an earlier version of git is installed, then this will just default to default to master as the initial branch flag will be ignored and hence this test will fail.
This is not really a significant issue, but did throw an error from a fresh install of Debian 10 for which the version of git from Debian is 2.20 (https://packages.debian.org/buster/git) hence this failed.
We note in the code here that it does rely on a newer version of git, but yet the test relies on the HEAD branch being main
. If we have the fallback logic to handle the case where we can’t set it to main, maybe we shouldn’t fail the test if it has to use it…
Two options to resolve this:
- Update the tests to not require the
main
branch (we could check whether the version of git supports the flag and then fall back to the alternative if it does not) - Update the fallback to manually switch the head branch over to
main
if trying to initialise the repo with the--initial-branch
flag does not exist
Error:
Summary of all failing tests
FAIL src/__tests__/init.test.ts
● init › git init › should offer to initialize a git repository
expect(received).toEqual(expected) // deep equality
Expected: "main"
Received: "master"
524 | }
525 | `);
> 526 | expect((await execa("git", ["branch", "--show-current"])).stdout).toEqual(
| ^
527 | "main"
528 | );
529 | });
at Object.<anonymous> (src/__tests__/init.test.ts:526:70)
● init › git init › should initialize git repo with `main` default branch
expect(received).toEqual(expected) // deep equality
Expected: "refs/heads/main"
Received: "refs/heads/master"
616 | `);
617 |
> 618 | expect(execaSync("git", ["symbolic-ref", "HEAD"]).stdout).toEqual(
| ^
619 | "refs/heads/main"
620 | );
621 | });
at Object.<anonymous> (src/__tests__/init.test.ts:618:62)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Let’s turn this into a separate Git issue or repurpose this one to triage it 😃
To be honest, I would rather that we just require that developing on the Wrangler2 project requires a recent version of git, in the same way that we require certain versions of node and TypeScript for instance.