Skip to content

feat(git): Add bin/git-server to check the relay against real providers - #161

Merged
vaind merged 1 commit into
ivan/git-grants-relay-scm-97ba4afrom
ivan/git-dev-server
Oct 22, 2026
Merged

vaind merged 1 commit into
ivan/git-grants-relay-scm-97ba4afrom
ivan/git-dev-server

Conversation

@vaind

@vaind vaind commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #156. Part of CW-2221.

The unit tests run the relay against a canned local server. None of them shows that a real git client gets through GitServer to GitHub or GitLab, with git's own request sequence, protocol v2, chunked pushes, and how git shows our refusals.

Approach

bin/git-server stands in for Sentry's git endpoint. It looks up the repository, signs grants and supplies the token. The real GitServer and GitRelay do the rest.

  • Credentials: the same ones bin/github-server and bin/gitlab-server read, from .credentials, env vars or flags. It loads those scripts to reuse their token handling.
  • Serve mode: bin/git-server github --repository OWNER/REPO serves the repository and prints a fetch grant, a push grant, and the git clone and git push commands that use them.
  • Check mode: --check serves on a free port, runs git against it, and exits non-zero if any check fails. Nothing is prompted and the user's git config isn't used, so it can run in CI once there are credentials for a test repository. It checks that:
    • ls-remote and a shallow clone work with a fetch grant
    • a push with a fetch grant, and a grant for another repository, are refused with git's remote: message
    • a token the provider rejects fails without git asking for credentials
    • a repository the token can't see fails with the provider's own message, e.g. GitHub's Repository not found., which the relay passes on
  • --push: also pushes a 256 KiB commit to a new branch and then deletes it. The commit is larger than http.postBuffer, so git sends it chunked. This writes to the repository, so it's opt-in.

Testing

  • All checks, including --push, pass in GitLab mode against a local HTTPS git http-backend with Basic auth. The backend received the push chunked, and the test branch was deleted afterwards.
  • Serve mode: cloned with the grant it printed.
  • GitHub: all checks, including --push, pass against an internal test repository through a GitHub App installation token. The test branch was deleted afterwards.
  • GitHub Enterprise: checked that the remote URL and username are right, but not run against a live instance.
  • GitLab: not yet run against a live instance.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

CW-2221

@vaind
vaind added this pull request to stack #159 October 20, 2026 20:21
@vaind
vaind force-pushed the ivan/git-dev-server branch 6 times, most recently from 722becb to 75da3a4 Compare October 21, 2026 09:36
@vaind
vaind marked this pull request as ready for review October 21, 2026 09:39
@vaind
vaind requested a review from a team as a code owner October 21, 2026 09:39
@vaind
vaind force-pushed the ivan/git-dev-server branch 3 times, most recently from edff5ce to ba90324 Compare October 22, 2026 06:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ba90324. Configure here.

Comment thread bin/git-server Outdated
@vaind
vaind force-pushed the ivan/git-dev-server branch 2 times, most recently from 043047b to 6eb1e91 Compare October 22, 2026 13:43
The unit tests run the relay against a canned local server, so nothing showed
that a real git client gets through GitServer to GitHub or GitLab: git's own
request sequence, protocol v2, chunked pushes, and how it shows our refusals.

bin/git-server stands in for Sentry's endpoint with the same credentials as
bin/github-server and bin/gitlab-server. It serves a repository and prints
grants for it, or with --check runs git against it and exits non-zero on a
failure, so it can move to CI once there are credentials for a test
repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vaind
vaind force-pushed the ivan/git-dev-server branch from 6eb1e91 to 4bf39a6 Compare October 22, 2026 15:16
@vaind
vaind merged commit d48b2a9 into main Oct 22, 2026
14 checks passed
@vaind
vaind deleted the ivan/git-dev-server branch October 22, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants