coder / coder/internal

Git Flow: coder/coder: implement endpoint to query branches from git remote

Abierto
#405 0 comentarios 0 reacciones 0 asignados Ver en GitHub
s
Lenguaje dominante
Sin datos de lenguaje
Estrellas
3
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Related to https://github.com/coder/internal/issues/404

In order to improve usability of Git repos, we want to have a way to quickly signal to the user if
- a Git repo they attempt to clone does not exist,
- the branch of the repo they attempted to clone does not exist,
- the user does not have the permission to clone the remote repo

Currently this is only detected when building the workspace, but ideally we should detect this up-front while the user is creating a workspace.

Add an endpoint in `coderd` to query a remote Git repo and return the list of branches on the remote:

```
GET /api/v2/users/{user}/git_repo/branches?repo={repo}&provider={provider_id}
```

* `git_repo` (required) should be the git URL of a remote repo to be queried
* If `provider` is set, authenticate with the provider using the logged in user's OAuth2 credentials. Otherwise assume no authentication.

Implementation notes:

* To query the remote branches, we can use an approach similar to `https://github.com/go-git/go-git/blob/main/_examples/ls-remote/main.go`
* We can also perform a basic syntax check of the Git repo URL using e.g. [github.com/chainguard-dev/git-urls](https://pkg.go.dev/github.com/chainguard-dev/git-urls). We should only warn and not block if the URL syntax appears incorrect; the likelihood of false positives is non-zero.
* Success criterion: we should be able to list remote branches of both Linux and Chromium without exploding 🙈

Guía de contribución

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

Línea de trabajo

Empieza por el enrutamiento de la API de coderd para el endpoint propuesto GET /api/v2/users/{user}/git_repo/branches; después, lee el ejemplo de ls-remote de go-git y las notas del paquete git-urls. Implementa los casos sin autenticación y los casos OAuth2 del proveedor, y verifica que se puedan listar las ramas remotas de los repositorios de Linux y Chromium.

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

Evaluación

Stack tecnológico
git, go
Área
api, authentication, backend
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.