gitbridge

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitbridge connects vx to git hosts. It imports upstream branches as changesets and exports effort changes as git commits on vx/ branches.

Each repo has a bare git mirror under the data directory. Imports fetch only the branch in use, shallow at first, and map git objects to vx objects in Postgres so later imports skip everything that did not change.

Index

Constants

View Source
const BranchPrefix = "vx/"

BranchPrefix is the only namespace vx ever pushes to.

Variables

View Source
var ErrBranchNotFound = errors.New("branch not found on the remote")

ErrBranchNotFound is returned when the remote has no such branch.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Store *store.Store
	Blobs blob.Store
	Dir   string // root for bare mirrors
	// GitHubToken returns a token for github.com, or "" for anonymous access.
	GitHubToken func() string
	// RepoToken returns a token for one GitHub repository (a GitHub App
	// installation token), or "" to fall back to GitHubToken. nil: only
	// GitHubToken is used.
	RepoToken func(ctx context.Context, repo store.Repo) (string, error)
	// GitHubAPI is the REST API base URL (tests point it at a fake).
	GitHubAPI string
	// GitHubGitBase is the base URL for git over HTTPS (tests override it).
	GitHubGitBase string
	// FirstDepth is how many commits the first import of a branch fetches.
	FirstDepth int
	// SyncDepth bounds how many new commits one sync imports.
	SyncDepth int
	Log       *slog.Logger
	// contains filtered or unexported fields
}

Bridge imports from and exports to git remotes.

func New

func New(st *store.Store, blobs blob.Store, dir string, githubToken func() string) *Bridge

New returns a bridge with defaults.

func (*Bridge) DefaultBranch

func (b *Bridge) DefaultBranch(ctx context.Context, repo store.Repo) (string, error)

DefaultBranch asks the remote which branch HEAD points to.

func (*Bridge) ExportBranch

func (b *Bridge) ExportBranch(ctx context.Context, repo store.Repo, baseSHA, branch string, commits []provider.Commit) ([]string, error)

ExportBranch writes commits on top of the git commit baseSHA and pushes them to branch, which must start with "vx/". It returns the git SHA of every commit, oldest first.

func (*Bridge) OpenPullRequest

func (b *Bridge) OpenPullRequest(ctx context.Context, repo store.Repo, pr provider.PullRequest) (provider.OpenedPR, error)

OpenPullRequest opens a PR for head, or updates the open one.

func (*Bridge) SyncBranch

func (b *Bridge) SyncBranch(ctx context.Context, repo store.Repo, branch string) (store.Branch, int, error)

SyncBranch fetches branch and imports its new first-parent commits.

func (*Bridge) UseRepoTokens added in v0.2.0

func (b *Bridge) UseRepoTokens(f func(ctx context.Context, repo store.Repo) (string, error))

UseRepoTokens sets RepoToken; the server passes the GitHub App's installation tokens this way.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL