Rationale#
I am not familiar with XRPC, but it appears that our XRPC responses
use types from types/, which are defined in terms of the types
exposed by external Go libraries such as go-git.
This makes it difficult to experiment with switching individual knot
servers to different Git libraries, as any hashes/refs must be
converted into types specific to go-git, thereby causing the entire
protocol to be go-git-centered.
Current status#
hook/setup.go
SetupRepousesgit.PlainOpento try to open the repo.appview/pages/pages.go
RepoTagsParamsuses a map keyed byplumbing.Hashs and a slice ofobject.Commits.appview/repo/tags.go
Repo.Tagsuses a map keyed byplumbing.Hashs.appview/repo/log.go
Repo.Commitusesplumbing.IsHash.appview/repo/artifact.go
Repo.DeleteArtifactusesplumbing.NewHash.appview/repo/tree.go
Repo.Treeusesplumbing.NewHash.appview/repo/archive.go
Repo.DownloadArchiveusesplumbing.ReferenceName.appview/repo/repo_util.go
uniqueEmailsusesobject.Commit.appview/repo/index.go
Repo.buildIndexResponseusesplumbing.NewHash.appview/ingester.go
Ingester.ingestArtifactusesplumbing.Hash.appview/commitverify/verify.go
GetVerifiedObjectCommitsandObjectCommitToNiceDiffuseobject.Commit.appview/models/pipeline.go
Trigger.TargetRefusesplumbing.ReferenceName.appview/models/artifact.go
Artifactusesplumbing.Hash.appview/db/artifact.go
GetArtifactusesplumbing.Hash.appview/state/knotstream.go
updateRepoLanguagesusesplumbing.ReferenceName.workflow/def.go
Constraint.MatchRefusesplumbing.ReferenceName.types/diff.go
NiceDiffusesobject.Signature.types/repo.go
Many types here useobject.Commit.types/tree.go
LastCommitInfousesplumbing.Hash.
These are largely trivial and could be defined ourselves. However, it may be difficult to remain compatible with the existing protocol, unless we closely match go-git's types.
Note that, in particular, go-git's plumbing.Hash is a [20]byte, which means that protocols that use it as the hash could only really support SHA-1 hashes. This may be undesirable but perhaps necessary for compatibility with existing knot servers?
Some alternative libraries use schemes such as this:
type Hash struct {
data [maxHashSize]byte
size int
}
Thank you for your summary! I generally agree with that we should remove the go-git dependency on xrpc types. Some notes about the list:
hook/is part of knot, so we can ignore it.plumbing.IsHashorplumbing.NewHashseems fine as they don't receive go-git types.I think defining our own Hash, Commit, Signature, and ReferenceName types for
types/package is good place to start.My opinion with this topic is that we shouldn't use xrpc to get git information at first place. Appview can fetch the entire repository on
refUpdateevents and directly gather informations from it. But this is long term goal and considering we would need types to represent git objects on appview anyway, I think defining custom types is definitely valuable.