Unquoted commit message is causing `npx all-contributors add` to fail on v7.0.0
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
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:
- 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 - Create
.all-contributorsrcwithcommitenabled:{ "projectName": "repo", "projectOwner": "example", "repoType": "github", "repoHost": "https://github.com", "files": ["README.md"], "imageSize": 100, "commit": true, "commitConvention": "angular", "contributors": [], "contributorsPerLine": 7 } - Commit the initial state:
git add -A && git commit -m init - Run
npx all-contributors add octocat code - 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) - 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 receivesabsolutePathFilesfromoptions.filesandoptions.config. From reading the code (I did not test it), a project path containing a space would breakgit addthe same way, and a path with shell metacharacters would be interpreted by the shell. Moving toexecFileorspawnwith 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
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de all-contributors/cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
all-contributors/cli#586 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
all-contributors/cli#584 ·
Los mantenedores suelen responder en 1 día
-
[BUG]: Markdown provided in `types[key].link` is injected as-is into HTMLAnchorElement's href attributePosiblemente ocupada @theworker02 la tomó hace 34 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 61/100
all-contributors/cli#520 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Additional Config File OptionsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
all-contributors/cli#499 · 2 comentarios · 6 reacciones ·
Los mantenedores suelen responder en 1 día
-
Consider adding a PR title checker to enforce angular / conventional commitsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertotype: ci type: enhancement type: infrastructure
Dificultad 2/5 1-3 horas Aptitud para principiantes 42/100
all-contributors/cli#482 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de all-contributors/cli
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
danilogiles/enki-browser#113 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
ux
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
evcc-io/evcc#35605 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
weavefox/awesome-opc#29 ·
Los mantenedores suelen responder en 1 día