Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #410
johnstcn opened this issue Feb 24, 2025 · 0 comments
Open
Tracked by #410
Labels
s estimated at 1-2 days of work

Comments

@johnstcn
Copy link
Member

johnstcn commented Feb 24, 2025

Related to #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. 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 🙈
@johnstcn johnstcn changed the title Git flow: coder/coder: implement endpoint to query branches from git remote Git Flow: coder/coder: implement endpoint to query branches from git remote Feb 24, 2025
@johnstcn johnstcn added the s estimated at 1-2 days of work label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s estimated at 1-2 days of work
Projects
None yet
Development

No branches or pull requests

1 participant