Migration: git repository operations → go/repo¶
Git repository operations — clone, commit, branch, checkout, tree inspection, the
in-memory and filesystem backends, RepoLike and its role interfaces,
ThreadSafeRepo, and the afero.Fs worktree view — have been extracted into the
standalone module gitlab.com/phpboyscout/go/repo (v0.1.0).
The billy→afero adapter that backs the worktree view was extracted alongside it as
gitlab.com/phpboyscout/go/aferobilly (v0.1.0), because it is useful to any
billy consumer and not VCS-specific.
This is a clean break, not a facade. GTB keeps only the props/config adapters —
the framework glue that turns GTB configuration into the module's Settings. Code
that used the git API must update its imports.
What stayed in GTB (no change for you)¶
pkg/vcs/repo keeps its adapters, with their names and behaviour intact:
SettingsFromProps(p)SettingsFromContainable(source, cfg, log, fs)NewRepoFromProps(p, ops...)NewThreadSafeRepoFromProps(p, opts...)
A tool that constructs repositories from GTB props is unaffected at the call site, though it now needs the module import for the types those adapters return.
What moved¶
Everything else. Repoint imports:
// before
import "gitlab.com/phpboyscout/go-tool-base/pkg/vcs/repo"
// after
import "gitlab.com/phpboyscout/go/repo"
Where a file uses both the git API and a GTB adapter, import both and alias the adapter — this keeps every module symbol unchanged:
import (
"gitlab.com/phpboyscout/go/repo"
gtbrepo "gitlab.com/phpboyscout/go-tool-base/pkg/vcs/repo"
)
r, err := gtbrepo.NewRepoFromProps(p)
found, err := repo.DiscoverRepository(path)
pkg/vcs/repo/aferobilly is gone; import gitlab.com/phpboyscout/go/aferobilly
if you used it directly.
Mocks¶
mocks/pkg/vcs/repo has been deleted. The module publishes mocks for all
eleven exported role interfaces:
Alias the import — a bare mocks collides as soon as a file needs mocks from two
modules.
Two settings changed shape¶
Both changes exist so that every input arrives through Settings: the module
now reads no environment of its own, which makes construction fully determined by
its arguments and keeps consumers' tests free of t.Setenv (which would forbid
t.Parallel()).
SSHSettings.Env removed¶
SSHSettings.Path is now always a resolved filesystem path, never an
environment-variable name. Apply the previous precedence at your call site with
the module's helper:
// before
settings.SSH.Path = cfgPath
settings.SSH.Env = "GITHUB_SSH_KEY"
// after — explicit path wins, else the named variable, else ""
settings.SSH.Path = repo.KeyPath(cfgPath, "GITHUB_SSH_KEY")
GTB's own adapter does exactly this, so config keys <forge>.ssh.key.path and
<forge>.ssh.key.env behave as before.
GTB_GIT_ENABLE_PROGRESS replaced by Settings.Progress¶
The environment variable and the package-level writer it set are gone. Progress is now a per-repository constructor argument:
This is worth wiring up for more than debugging: it receives the remote server's
sideband output, which carries pre-receive hook rejection reasons and the
"create a merge request at …" URLs that arrive on no other channel. Push backfills
it from Settings the same way it backfills Auth.
Because the stream is remote-controlled text and may contain terminal control characters, send it to a terminal or a buffer rather than to a log aggregator.
Documentation¶
- Module guides: repo.go.phpboyscout.uk
- Adapter bridge: aferobilly.go.phpboyscout.uk
- GTB wiring: Repo component page