Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Unquoted commit message is causing `npx all-contributors add` to fail on v7.0.0

Abierto Apto para principiantes
#587 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, javascript, node.js
Área
cli, tooling

Línea de trabajo

Empieza en dist/util/git.js, en spawnGitCommand, donde el issue señala la construcción del comando de shell, y revisa los puntos de llamada de los comandos de Git para commit y add. Sustituye la ejecución de cadenas de shell por una ejecución basada en argumentos, como se describe en el issue. Reproduce el problema con commit habilitado y ejecuta npx all-contributors add octocat code; se considera terminado cuando el commit se completa correctamente con el mensaje completo y las rutas que contienen espacios se manejan como argumentos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

[!NOTE]
I have ran into this issue after upgrading from [email protected] to the latest v7 release.

I have asked LLM to perform an initial debug and generate the following report, which I have manually checked and modified for clarity.

Describe the bug

In v7.0.0, all-contributors add fails at the commit step when "commit": true is set in .all-contributorsrc. The files are updated and staged, then the commit fails with:

Error: error: pathspec 'add' did not match any file(s) known to git
error: pathspec '@octocat' did not match any file(s) known to git
error: pathspec 'as' did not match any file(s) known to git
error: pathspec 'a' did not match any file(s) known to git
error: pathspec 'contributor' did not match any file(s) known to git

The cause is in dist/util/git.js. spawnGitCommand builds one shell string and runs it through exec:

await promisify(exec)(`git ${args.join(' ')}`)

The commit message is passed in args (['commit', '-m', commitMessage]) but is never quoted. The shell splits it on spaces, so git receives commit -m feat: Add @octocat as a contributor. Only feat: is treated as the message, and the remaining words are treated as pathspecs.

This is a regression. 6.26.1 calls spawn('git', args) with an argument array, so no shell is involved and the message arrives intact.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new directory with a git repository and a README that has the contributors markers:
    mkdir ac-repro && cd ac-repro
    git init && git remote add origin https://github.com/example/repo.git
    npm init -y
    npm i [email protected]
    printf '# t\n\n## Contributors\n\n<!-- ALL-CONTRIBUTORS-LIST:START -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n' > README.md
    
  2. Create .all-contributorsrc with commit enabled:
    {
      "projectName": "repo",
      "projectOwner": "example",
      "repoType": "github",
      "repoHost": "https://github.com",
      "files": ["README.md"],
      "imageSize": 100,
      "commit": true,
      "commitConvention": "angular",
      "contributors": [],
      "contributorsPerLine": 7
    }
    
  3. Commit the initial state: git add -A && git commit -m init
  4. Run npx all-contributors add octocat code
  5. See the error:
    file:///.../node_modules/all-contributors-cli/dist/util/git.js:43
        throw new Error(msg)
              ^
    
    Error: error: pathspec 'add' did not match any file(s) known to git
    error: pathspec '@octocat' did not match any file(s) known to git
    error: pathspec 'as' did not match any file(s) known to git
    error: pathspec 'a' did not match any file(s) known to git
    error: pathspec 'contributor' did not match any file(s) known to git
    
        at spawnGitCommand (.../dist/util/git.js:43:11)
    
  6. Run git status --short. Both files are staged but nothing was committed:
    M  .all-contributorsrc
    M  README.md
    

Expected behavior

git commit receives the whole message as a single argument and the commit is created, as it was in 6.x (for example docs: add @octocat as a contributor).

A fix is to pass the arguments to execFile or spawn instead of building a shell string, as 6.26.1 did.

Screenshots

Not applicable, the full error output is above.

Additional context

  • Node.js: v24.22.1
  • Workarounds for 7.0.0: pass --no-commit (or set "commit": false) and commit manually.
  • The same string-joining happens for git add, which receives absolutePathFiles from options.files and options.config. From reading the code (I did not test it), a project path containing a space would break git add the same way, and a path with shell metacharacters would be interpreted by the shell. Moving to execFile or spawn with an argument array fixes both.
Lenguaje dominante
JavaScript
Estrellas
424
Forks
151
Merge medio
2 d 1 h
PR fusionados (30 d)
15

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de all-contributors/cli

Todos los issues de all-contributors/cli

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.