openPublicStore: tighten bare-repo guard with git rev-parse --is-bare-repository

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

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
git, typescript
Área
backend

Línea de trabajo

Empieza en apps/api/src/store/public.ts, en openPublicStore, y revisa la comprobación actual de .git alrededor de las líneas 80-87. Comprueba el resultado síncrono de git rev-parse --is-bare-repository para rutas de repositorio bare, non-bare y no válidas; se considera terminado cuando los repositorios non-bare o las comprobaciones fallidas generan el error de remediación con la estructura existente, mientras que los repositorios bare válidos continúan.

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

Descripción

Background

PR #86's openPublicStore (apps/api/src/store/public.ts:80-87) guards against non-bare clones via:

```ts
if (existsSync(join(repoPath, '.git'))) {
throw new Error(`CFP_DATA_REPO_PATH=${repoPath} looks like a non-bare clone ...`);
}
```

This catches the common misconfiguration (someone ran `git clone` instead of `git clone --bare`) but isn't the authoritative check. A directory created with `git init` (non-bare, no `.git` subdir because the path IS the working tree's gitdir... wait, no — `git init` creates `.git/`) — actually, the more interesting failure mode is something like a partially-initialized directory, or a future case where someone manually constructs a layout the existsSync check misses.

The authoritative check is git's own:

```bash
git -C "$repoPath" rev-parse --is-bare-repository

Prints 'true' for a bare repo, 'false' otherwise; exits non-zero if not a repo at all.

```

Proposed change

Replace the existsSync check in `openPublicStore` with a synchronous spawn of `git rev-parse --is-bare-repository` against `repoPath`, asserting the output is `true`. On `false` or non-zero exit, throw the same shaped error with the same remediation message.

Cost: one subprocess at boot (already paying many). Benefit: the guard catches every non-bare shape, not just the one we thought of.

Why backlog

The current guard catches the realistic misconfiguration today. This is hardening, not a fix. Trivially-sized PR (~10 lines), open to picking up anytime.

Filed as follow-up from PR #86.

Lenguaje dominante
TypeScript
Estrellas
1
Forks
1
Merge medio
1 d 20 h
PR fusionados (30 d)
25

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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 CodeForPhilly/codeforphilly-ng

Todos los issues de CodeForPhilly/codeforphilly-ng

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.