From e1e78988aa6d37ec2be366556af5a071a66332fb Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Wed, 7 Aug 2024 21:27:37 +0800 Subject: [PATCH] chore: Add docs for RepoStore methods (#64283) --- internal/database/repos.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/internal/database/repos.go b/internal/database/repos.go index e502195deb2..d9ccb5e6a47 100644 --- a/internal/database/repos.go +++ b/internal/database/repos.go @@ -72,13 +72,40 @@ type RepoStore interface { Count(context.Context, ReposListOptions) (int, error) Create(context.Context, ...*types.Repo) error Delete(context.Context, ...api.RepoID) error + // Get gets information about a single repo. + // + // Prefer using GetByIDs or GetReposSetByIDs for bulk retrieval. + // + // Returns database.RepoNotFoundErr if the repo was not found. + // Returns types.BlockedRepoError if the repo was blocked. Get(context.Context, api.RepoID) (*types.Repo, error) + // GetByIDs returns a slice containing information about repos present on the instance. + // + // The slice may have fewer entries than the number of input RepoIDs, + // due to repos not being found or having been deleted/blocked etc. + // + // Even if the number of elements matches, the caller may not assume anything + // about ordering. Use the ID field on each types.Repo value instead. GetByIDs(context.Context, ...api.RepoID) ([]*types.Repo, error) + // GetByName is analogous to Get but using an api.RepoName. + // + // Prefer using Get over GetByName for trusted input. + // + // Returns database.RepoNotFoundErr if the repo was not found. + // Returns types.BlockedRepoError if the repo was blocked. GetByName(context.Context, api.RepoName) (*types.Repo, error) GetByHashedName(context.Context, api.RepoHashedName) (*types.Repo, error) GetFirstRepoNameByCloneURL(context.Context, string) (api.RepoName, error) GetFirstRepoByCloneURL(context.Context, string) (*types.Repo, error) + // GetReposSetByIDs returns a map containing information about repos present on the instance. + // + // The map may have fewer key-value pairs than the number of input RepoIDs, + // due to repos not being found or having been deleted/blocked etc. GetReposSetByIDs(context.Context, ...api.RepoID) (map[api.RepoID]*types.Repo, error) + // GetRepoDescriptionsByIDs returns descriptions about repos present on the instance. + // + // The map may have fewer key-value pairs than the number of input RepoIDs, + // due to repos not being found or having been deleted/blocked etc. GetRepoDescriptionsByIDs(context.Context, ...api.RepoID) (map[api.RepoID]string, error) List(context.Context, ReposListOptions) ([]*types.Repo, error) ListMinimalRepos(context.Context, ReposListOptions) ([]types.MinimalRepo, error)