From 4b28f2e1cd4aaecd4cadd803d4c995b982231845 Mon Sep 17 00:00:00 2001 From: guy-har <60321938+guy-har@users.noreply.github.com> Date: Sun, 29 Nov 2020 16:33:15 +0200 Subject: [PATCH] catalog interface | change Dereference to RevParse (#972) --- catalog/rocks/catalog.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/catalog/rocks/catalog.go b/catalog/rocks/catalog.go index a1a3dd82a2e..cacd817bf8d 100644 --- a/catalog/rocks/catalog.go +++ b/catalog/rocks/catalog.go @@ -7,7 +7,7 @@ import ( // Basic Types -// DiffType represents a changed state for a given entry (added, removed, changed, conflict) +// DiffType represents a changed state for a given entry type DiffType uint8 const ( @@ -17,6 +17,21 @@ const ( DiffTypeConflict ) +// ReferenceType represents the type of the reference +type ReferenceType uint8 + +const ( + ReferenceTypeCommit ReferenceType = iota + ReferenceTypeTag + ReferenceTypeBranch +) + +type Reference interface { + Type() ReferenceType + Branch() Branch + CommitID() CommitID +} + // function/methods receiving the following basic types could assume they passed validation type ( // StorageNamespace is the URI to the storage location @@ -147,9 +162,6 @@ type Catalog interface { // GetBranch gets branch information by branch / repository id GetBranch(ctx context.Context, repositoryID RepositoryID, branchID BranchID) (Branch, error) - // Dereference translates ref to commit id - Dereference(ctx context.Context, repositoryID RepositoryID, ref Ref) (CommitID, error) - // Log lists commits in repository // The 'from' is used to get all commits after the specified commit id // The 'amount' specifies the maximum number of commits the call will return @@ -260,8 +272,8 @@ type RefManager interface { // DeleteRepository deletes the repository DeleteRepository(ctx context.Context, repositoryID RepositoryID) error - // Dereference translates Ref to the corresponding CommitID - Dereference(ctx context.Context, repositoryID RepositoryID, ref Ref) (CommitID, error) + // RevParse returns the Reference matching the given Ref + RevParse(ctx context.Context, repositoryID RepositoryID, ref Ref) (Reference, error) // GetBranch returns the Branch metadata object for the given BranchID GetBranch(ctx context.Context, repositoryID RepositoryID, branchID BranchID) (*Branch, error)