Git Flow: coder/coder: implement endpoint to query branches from git remote
- 主要言語
- 言語のデータがありません
- スター
- 3
- フォーク
- 0
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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 🙈
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
提案されているエンドポイント GET /api/v2/users/{user}/git_repo/branches に対応する coderd API のルーティングから始め、次に go-git の ls-remote の例と git-urls パッケージの notes を読んでください。未認証の場合と provider の OAuth2 の場合を実装し、Linux および Chromium のリポジトリで remote branches を一覧表示できることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- git, go
- 領域
- api, authentication, backend
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100