question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: Tests fail if old version of git installed on system

See original GitHub issue

What 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:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JacobMGEvanscommented, Sep 8, 2022

We could add a hook to the scripts for the project that checks the current git version and displays an error/warning.

Let’s turn this into a separate Git issue or repurpose this one to triage it 😃

1reaction
petebacondarwincommented, Sep 8, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git Error after 17.1.4 update - Visual Studio Feedback
[severity:I'm unable to use this version] [regression] [worked-in:17.1.3] After update to VS 2022 17.1.4, Git is showing error: One or more errors occurred....
Read more >
git-bisect Documentation - Git
Each time git bisect checks out a commit, you test if that commit has the property. If it does, mark the commit as...
Read more >
VS Code Error: spawn git ENOENT - Stack Overflow
We need to install Git to use the Git History (git log) extension in VS Code. Otherwise we will see this when running...
Read more >
Troubleshooting Git - GitLab Docs
In case you're running an older version of Git (< 2.9), ... Sometimes, when cloning old or large repositories, the following error is...
Read more >
Installing and upgrading Git | Bitbucket Data Center and ...
[Security vulnerability CVE-2016-2324 & CVE-2016-2315] If you are running a Git version older than 2.4.11, 2.5.5, 2.6.6 or 2.7.4 (all ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found