With the upcoming introduction of KnotMirror (git repo mirrors against entire network), we technically don't need most xrpc methods to interact with git repos, but third-party services might still want to depend on them. For example, users might make Knot-local web interface or third-party AppView without syncing from network.
Standardizing the hydrated ViewModel doesn't make much sense as they will change quite often. While KnotMirror reduces the "Knot api outdated" problem, we still want some kind of API to interact with knot and want to share same schema between internal and public APIs.
So instead of defining View methods from Knot, we can define Domain methods more closer to fundamental git objects (hope this explanation makes sense.) Instead of sh.tangled.repo.{branch,tag,tree} returning hydrated objects to render the repository, we can generalize them and make xrpc methods that can directly interact with core git concepts like trees and branches.
The implementation might not change much. The goal here is to make xrpc methods more git-friendly and closer to the internal domain than appview-specific concepts (ViewModel). Yeah, this proposal is more for organization purpose.
current knot xrpc methods related to the repository#
- (procedure)
repo.deleteBranch - (procedure)
repo.forkStatus - (procedure)
repo.forkSync - (procedure)
repo.hiddenRef - (procedure)
repo.mergeCheck - (procedure)
repo.merge - (procedure)
repo.setDefaultBranch - (query)
repo.archive - (query) `repo.blob
- (query)
repo.branch - (query)
repo.branches - (query)
repo.compare - (query)
repo.diff - (query)
repo.getDefaultBranch - (query)
repo.languages - (query)
repo.log - (query)
repo.tag - (query)
repo.tags - (query)
repo.tree
Few problems: repo.forkStatus and repo.mergeCheck are more closer to query than procedure, repo.branch naming is misleading as it basically returns a resolved commit, "default branch" is already well-known as different term in git; "HEAD", most methods are not following lexicon naming conventions.
new git xrpc methods#
updated methods:
- (procedure)
git.deleteBranch - (query)
git.getForkStatus - (procedure)
git.pullUpstream - (procedure)
git.createHiddenRef - (query)
git.analyzeMerge - (procedure)
git.applyPatch - (procedure)
git.putHead - (query)
git.getArchive - (query)
git.getEntity(repo, ref, path)andgit.getBlob(repo, oid) - (query)
git.getCommit - (query)
git.listBranches - (query)
git.getDiff(repo, base, head) - (query)
git.getDiff(repo, head) - (query)
git.getHead - (query)
git.listLanguages - (query)
git.listCommits - (query)
git.getTag - (query)
git.listTags - (query)
git.getTree(repo, ref, path)
and some new methods:
20. (query) git.getObject(repo, oid, type?)
21. (query) git.listRefs(repo, prefix?)
22. (query) git.resolveRef(repo, ref)
23. (subscription) git.subscribeRefs(repo) (to replace /events endpoint)
summary:
- move under
sh.tangled.git.*to be used as generic git xrpc interface. For example, all query methods can be supported from KnotMirror too. - follow lexicon naming conventions
- merge some duplicated methods like
repo.compareandrepo.diffby makingbaseoptional. - provide generalized methods like
git.listRefsandgit.getObject. For example,git.listBranchesis equivalent togit.listRefs(prefix="refs/heads/"). We can share same schema between lexicons. git.getBlobwill always serve the raw content. usegit.getEntityto get structured metadata (this method won't return the content)