Interface RefService
-
Method Summary
Modifier and TypeMethodDescriptioncreateBranch
(CreateBranchRequest request) Create branch with the information provided in therequest
.createTag
(CreateTagRequest request) Create tag with the information provided in therequest
.getBranches
(RepositoryBranchesRequest request, PageRequest pageRequest) Retrieves a paged list ofbranches
for the specified repository, optionally filtered by the provided starting text.getDefaultBranch
(Repository repository) Retrieves the default branch for the specified repository.getMetadataByRefs
(RefMetadataRequest request) Retrieves the associated metadata based on a given collection of refs in a repository.getTags
(RepositoryTagsRequest request, PageRequest pageRequest) Retrieves a paged list oftags
for the specified repository, optionally filtered by the provided starting text.resolveRef
(ResolveRefRequest request) resolveRefs
(ResolveRefsRequest request) Attempts to resolve multiple refs at once, returning a map with the successfully resolved IDs linked to their resolvedrefs
.void
setDefaultBranch
(Repository repository, String branchName) Sets the default branch for the specified repository.void
streamBranches
(RepositoryBranchesRequest request, BranchCallback callback) Streamsbranches
to a callback class, for the specified repository, and where the branches match the request.void
streamTags
(RepositoryTagsRequest request, TagCallback callback) Streamstags
to a callback class, for the specified repository, and where the tags match the request.
-
Method Details
-
createBranch
Create branch with the information provided in therequest
.- Parameters:
request
- the branch creation request- Returns:
- the created branch
- Throws:
RepositoryHookVetoedException
- if branch creation was canceled by one or morerepository-hooks
-
createTag
Create tag with the information provided in therequest
.- Parameters:
request
- the tag creation request- Returns:
- the created tag
- Throws:
RepositoryHookVetoedException
- if tag creation was canceled by one or morerepository-hooks
-
getBranches
@Nonnull Page<Branch> getBranches(@Nonnull RepositoryBranchesRequest request, @Nonnull PageRequest pageRequest) Retrieves a paged list ofbranches
for the specified repository, optionally filtered by the provided starting text.- Parameters:
request
- request parameters for this query, including repository, filter text and orderingpageRequest
- the page request defining the page start and limit- Returns:
- a page containing 0 or more branches
-
getDefaultBranch
@Nonnull Branch getDefaultBranch(@Nonnull Repository repository) throws NoDefaultBranchException, RepositoryInconsistentException, RepositoryOfflineException Retrieves the default branch for the specified repository.If the repository is newly created and no commits have been pushed to it, its default branch will not yet exist. As a result, for new repositories, this method can throw
NoDefaultBranchException
. If you want to know what the configured default branch is, regardless of whether the ref actually exists, useRepositoryService.getDefaultBranch(Repository)
instead.- Parameters:
repository
- the repository to retrieve the default branch for- Returns:
- the default branch
- Throws:
NoDefaultBranchException
- when no default branch is configured for the repositoryRepositoryInconsistentException
- when the repository is inconsistentRepositoryOfflineException
- when the repository is offline- See Also:
-
getMetadataByRefs
Retrieves the associated metadata based on a given collection of refs in a repository.- Parameters:
request
- request parameters for this query, including repository and refs to find metadata for- Returns:
- a containing the associated metadata keyed by
Ref
-
getTags
@Nonnull Page<Tag> getTags(@Nonnull RepositoryTagsRequest request, @Nonnull PageRequest pageRequest) Retrieves a paged list oftags
for the specified repository, optionally filtered by the provided starting text.- Parameters:
request
- request parameters for this query, including repository, filter text and orderingpageRequest
- the page request defining the page start and limit- Returns:
- a page containing 0 or more tags
-
resolveRef
Attempts to resolve aRef
from the providedrefId
. Specifically, the object is resolved as either aBranch
orTag
. If the providedrefId
references something else, such as a commit hash, tree or blob,null
is returned.If the ID is expected to match a ref of a specific
type
, the request may be explicitly limited to thattype
.The exact behavior of this method may vary between SCMs. For example, when provided with a commit hash, the SCM implementor may choose to return a
Branch
orTag
which references that commit, instead of returningnull
. -
resolveRefs
Attempts to resolve multiple refs at once, returning a map with the successfully resolved IDs linked to their resolvedrefs
.If an ID is expected to match a
branch
ortag
, it should be included in the relevant set. IDs for which the type is not known in advance should be included in thegeneric ref set
.The exact behavior of this method may vary between SCMs. For example, when provided with a commit hash, the SCM implementor may choose to resolve it to a
Branch
orTag
which references that commit, or they may choose to always omit it from the returned map.- Parameters:
request
- describes the branch, tag and unspecified ref IDs to resolve, and the repository to resolve them in- Returns:
- a map containing the successfully resolved IDs, which may be empty but never
null
- Since:
- 4.6
-
setDefaultBranch
Sets the default branch for the specified repository. Support for this operation is SCM-specific, and different SCMs may apply different rules to what values are supported.- Parameters:
repository
- the repository to update the default branch forbranchName
- the branch to mark as the default within the repository- Throws:
FeatureUnsupportedScmException
- if the SCM for the specified repository does not support updating the default branch
-
streamBranches
Streamsbranches
to a callback class, for the specified repository, and where the branches match the request.- Parameters:
request
- request parameters for this query, including repository, filter text and orderingcallback
- a callback to receive thebranches
- Since:
- 5.1
-
streamTags
Streamstags
to a callback class, for the specified repository, and where the tags match the request.- Parameters:
request
- request parameters for this query, including repository, filter text and orderingcallback
- a callback to receive thetags
-