Add squash and collection commands#18
Open
HuiJun wants to merge 2 commits into
Open
Conversation
Add two new git-style/layer1 commands to reach closer feature parity
with the flexo-mms-layer1-service recent endpoints:
- squash <srcLock> <dstLock>: POST /orgs/{org}/repos/{repo}/squash,
squashing the linear commit path between two locks into a single diff.
- collection {list|get|create|query}: org-level collections
(/orgs/{org}/collections), lightweight groupings of refs queryable
as a union graph.
FlexoMmsClient gains squash, listCollections, getCollection,
createCollection, getCollectionModel and queryCollection methods plus a
Collection model POJO and RDF parsing helper, all matching existing
client/command conventions.
Adds 8 client tests and 2 command smoke tests (308 tests total).
Collection create (--ref names) and squash (lock names) resolved ref IRIs against the client base URL, but layer1-service stores and validates refs under its configured root context (e.g. http://layer1-service), causing HTTP 404 'Ref does not exist'. Add FlexoMmsClient.getServerRootContext() which derives the server root from an existing branch commit IRI, and route resolveBranchIri() and resolveLockIri() through it. Absolute http(s) IRIs pass through unchanged. Simplify CollectionCommand.CreateCommand to use resolveBranchIri(). Add tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the CLI toward feature parity with layer1-service by adding two
recently-added server capabilities:
squash— squash the linear commit path between two locks into asingle diff on the newer lock's commit (
POST /orgs/{org}/repos/{repo}/squash).collection— manage Collections, layer1's lightweight groupingsof refs (branches/locks/scratches) that can be read and queried as a
union graph (
/orgs/{org}/collections).Commands
squash
flexo squash
<dstLock>must be the newer commit. Accepts lock names (resolved tolock IRIs under the current org/repo) or full IRIs. Prints the resulting
squashed commit id.
collection
flexo collection list
flexo collection get
flexo collection create --ref --ref ...
flexo collection query (-q | -i ) -o
createtakes one or more--refvalues; each is resolved to a branchIRI under the current org/repo (or passed through if already a full IRI).
queryruns SPARQL across the union of the collection's collected refgraphs; reads the query from
-q/--queryor-i/--input, writesresults to
-o/--outputor stdout.Implementation
FlexoMmsClient:squash,listCollections,getCollection,createCollection,getCollectionModel,queryCollection, plus RDFparsing of collections (
parseCollectionsFromRdf).Collectionmodel POJO (id,name,etag,collectedRefs).SquashCommandandCollectionCommand(withlist/get/create/querysubcommands), registered inFlexoCLI+ help listing.against the server's configured root context (e.g.
http://layer1-service),not the client base URL, since layer1 stores and validates refs under
that root.
getServerRootContext()derives it from an existing branch'scommit IRI; absolute
http(s)IRIs pass through unchanged.Follows existing command/client patterns (
BaseCommand,createClient,ConsoleUtil, Turtle bodies,extractCommitId).Testing
./gradlew clean test— green.FlexoMmsClienttests: squash success/error, collectionlist/get/create (incl. empty-refs guard)/query success/error, and
ref-resolution (server root context + absolute passthrough).
test style).
feature):
collection create --ref master --ref feature-aresolves tohttp://layer1-service/...IRIs and creates;list/getround-trip;queryreturns the correct union count.squashreaches the server withthe correct path/body (verified via the server's precise
"lock does not exist" response).
Notes / limitations
command yet (can't create the two locks squash operates on). The squash
client method is unit-tested and the request path/body are verified
against the live server.
the same commit — a server-side union-graph construction issue
(duplicate
FROM/FROM NAMED), not a CLI bug; the CLI sends a valid query.