npm/git

[BUG] npm run test fails for all git versions below 2.28.0

ferdinando-ferreira opened this issue · 1 comments

What / Why

npm run test for this package fails (for instance) on the latest release of Ubuntu (20.10 groovy) fully upgraded. It happens due the latest stable version of the git command line being 2.27.0 on that distro.

When

Fails for every attempt with a git version below 2.28.0

Where

  • n/a

How

Current Behavior

Git cloning the repository on any machine with a version of git installed below 2.28.0 and running npm run test fails

Steps to Reproduce

On any machine with git below 2.28.0 installed (for instance, a fully upgraded Ubuntu 20.10 machine) execute the following commands:

mkdir tests
cd tests
git clone https://github.com/npm/git.git git
cd git/
npm install
npm run test

The expected result would be all tests passing. The obtained result is:

> @npmcli/git@2.0.6 test /home/user/tests/git
> tap

 PASS  test/env.js 4 OK 111.436ms
 PASS  test/find.js 3 OK 130.919ms
 PASS  test/index.js 1 OK 55.775ms
 PASS  test/is-clean.js 6 OK 894.282ms
 PASS  test/is.js 5 OK 115.166ms
 PASS  test/lines-to-revs.js 22 OK 99.539ms
 PASS  test/opts.js 2 OK 77.576ms
 FAIL  test/revs.js
 ✖ command failed

      if (code || signal)
        rej(Object.assign(new Error('command failed'), result))
--------------------------^
      else
        res(result)

  test: setup
  stack: |
    ChildProcess.<anonymous> (node_modules/@npmcli/promise-spawn/index.js:63:27)
  at:
    line: 63
    column: 27
    file: node_modules/@npmcli/promise-spawn/index.js
    function: ChildProcess.<anonymous>
  cmd: /usr/bin/git
  args:
    - init
    - -b
    - main
  code: 129
  signal: null
  stdout: ""
  stderr: >+
    error: unknown switch `b'

    usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>]

        --template <template-directory>
                              directory from which templates will be used
        --bare                create a bare repository
        --shared[=<permissions>]
                              specify that the git repository is to be shared amongst several users
        -q, --quiet           be quiet
        --separate-git-dir <gitdir>
                              separate git dir from working tree
        --object-format <hash>
                              specify the hash algorithm to use

  tapCaught: returnedPromiseRejection

 FAIL  test/revs.js
 ✖ command failed

      if (code || signal)
        rej(Object.assign(new Error('command failed'), result))
--------------------------^
      else
        res(result)

  test: point latest at HEAD
  stack: |
    ChildProcess.<anonymous> (node_modules/@npmcli/promise-spawn/index.js:63:27)
  at:
    line: 63
    column: 27
    file: node_modules/@npmcli/promise-spawn/index.js
    function: ChildProcess.<anonymous>
  cmd: /usr/bin/git
  args:
    - ls-remote
    - /home/user/tests/git/test/revs
  code: 128
  signal: null
  stdout: ""
  stderr: |
    fatal: '/home/user/tests/git/test/revs' does not appear to be a git repository
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
  tapCaught: returnedPromiseRejection

 FAIL  test/revs.js
 ✖ command failed

      if (code || signal)
        rej(Object.assign(new Error('command failed'), result))
--------------------------^
      else
        res(result)

  test: add a latest branch, point to 1.2.3 version
  stack: |
    ChildProcess.<anonymous> (node_modules/@npmcli/promise-spawn/index.js:63:27)
  at:
    line: 63
    column: 27
    file: node_modules/@npmcli/promise-spawn/index.js
    function: ChildProcess.<anonymous>
  cmd: /usr/bin/git
  args:
    - reset
    - --hard
    - version-1.2.3
  code: 128
  signal: null
  stdout: ""
  stderr: >
    fatal: ambiguous argument 'version-1.2.3': unknown revision or path not in the
    working tree.

    Use '--' to separate paths from revisions, like this:

    'git <command> [<revision>...] -- [<file>...]'
  tapCaught: returnedPromiseRejection

 FAIL  test/revs.js
 ✖ command failed

      if (code || signal)
        rej(Object.assign(new Error('command failed'), result))
--------------------------^
      else
        res(result)

  test: check the revs
  stack: |
    ChildProcess.<anonymous> (node_modules/@npmcli/promise-spawn/index.js:63:27)
  at:
    line: 63
    column: 27
    file: node_modules/@npmcli/promise-spawn/index.js
    function: ChildProcess.<anonymous>
  cmd: /usr/bin/git
  args:
    - ls-remote
    - /home/user/tests/git/test/revs
  code: 128
  signal: null
  stdout: ""
  stderr: |
    fatal: '/home/user/tests/git/test/revs' does not appear to be a git repository
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
  tapCaught: returnedPromiseRejection

 FAIL  test/revs.js 4 failed of 4 921.343ms
 ✖ command failed
 ✖ command failed
 ✖ command failed
 ✖ command failed

 PASS  test/should-retry.js 3 OK 90.277ms
 PASS  test/clone.js 115 OK 22s
 PASS  test/which.js 5 OK 1s
 PASS  test/spawn.js 6 OK 4s


  🌈 SUMMARY RESULTS 🌈


 FAIL  test/revs.js 4 failed of 4 921.343ms
 ✖ command failed
 ✖ command failed
 ✖ command failed
 ✖ command failed

Suites:   1 failed, 11 passed, 12 of 12 completed
Asserts:  4 failed, 172 passed, of 176
Time:     33s

Expected Behavior

npm run test should succeed in an unchanged repository

Submitted #13, which would close this issue in a backward compatible way.