Enum Class GitRefPattern
- All Implemented Interfaces:
Serializable,Comparable<GitRefPattern>,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRef pattern denoting local branches.Ref pattern denoting open pull requests.Ref pattern denoting remote branches (agnostic of remote name).Ref pattern denoting tags. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringRetrieves the default sort flag, to be applied to refs when no more-specific sort is desired (or makes sense).String[]Retrieves the components that make up this pattern'spath.getPath()Retrieves the path under the.gitdirectory containing all refs for this pattern.Retrieves a non-force refspec for this pattern.getRefspec(boolean force) Retrieves a refspec for this pattern.getSearchOrder(String ref) Applies the git precedence ordering for the provided ref, constrained by this pattern, to produce an ordered list of search candidates.Qualifies the providedrefaccording this pattern.sort(com.atlassian.bitbucket.repository.RefOrder order) Retrieves a flag that may be provided to thegit rev-list --sort=option to sort refs in the specifiedorder.Unqualifies the providedrefaccording to this pattern.static GitRefPatternReturns the enum constant of this class with the specified name.static GitRefPattern[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
HEADS
Ref pattern denoting local branches. -
PULL_REQUESTS
Ref pattern denoting open pull requests. -
REMOTES
Ref pattern denoting remote branches (agnostic of remote name). -
TAGS
Ref pattern denoting tags.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getComponents
Retrieves the components that make up this pattern'spath.- Returns:
- the path components for this pattern
-
getPath
Retrieves the path under the.gitdirectory containing all refs for this pattern.Note: Paths returned from this method will always end with a trailing
/.- Returns:
- the ref path for this pattern
-
getRefspec
Retrieves a non-force refspec for this pattern. The refspec is structured so that all refs that match this pattern on the remote will update refs of the same pattern locally. For example, forHEADS, the refspec will berefs/heads/*:refs/heads/*.- Returns:
- a refspec for refs matching this pattern
-
getRefspec
Retrieves a refspec for this pattern. optionally including a leading+to allow forced updates. The refspec is structured so that all refs that match this pattern on the remote will update refs of the same pattern locally. For example, forHEADS, the refspec will be+refs/heads/*:refs/heads/*ifforceistrue, andrefs/heads/*:refs/heads/*otherwise.- Parameters:
force- true for a forced update- Returns:
- a refspec for refs matching this pattern, optionally allowing forced updates
-
getSearchOrder
Applies the git precedence ordering for the provided ref, constrained by this pattern, to produce an ordered list of search candidates. That means that where the git precedence would search across branches and tags and remotes, the returned list only searches within a given type, such as tags, but it contains paths under the.gitdirectory in the same ordergitwould search them.- Parameters:
ref- the ref for which to build a search order- Returns:
- a list of possible locations for matching the provided ref, in order of their precedence in git
- Throws:
IllegalArgumentException- if the providedrefis empty or blankNullPointerException- if the providedrefisnull
-
qualify
Qualifies the providedrefaccording this pattern. The returned value is suitable for use as a ref'sID.Note: The implementation of this method attempts to detect when a fully- or partially-qualified ref is passed and further qualify the ref as appropriate. However, this may result in incorrect output when qualifying a ref that looks fully- or partially-qualified but actually isn't. For example, qualifying a ref like
"refs/heads/master"will produce the same string, from theHEADSpattern, which is wrong if the branch's display name was actually"refs/heads/master", meaning the qualified ref is actually"refs/heads/refs/heads/master".- Parameters:
ref- the ref to qualify, which may be fully- or partially-qualified- Returns:
- a fully qualified ref according to this pattern
- Throws:
IllegalArgumentException- if the providedrefis empty or blankNullPointerException- if the providedrefisnull
-
sort
Retrieves a flag that may be provided to thegit rev-list --sort=option to sort refs in the specifiedorder.- Parameters:
order- the order to apply to refs- Returns:
- a
git rev-list --sort=flag for producing the specified order
-
unqualify
Unqualifies the providedrefaccording to this pattern. The returned value is suitable for use as a ref'sdisplay ID.This process is the logical negation of
qualifying a ref. It removes the path for this pattern from the providedrefif it is present. If the provided ref is partially-qualified, the partial qualification is removed.Examples, using the
HEADSpattern:"refs/heads/master"->"master""heads/master"->"master""master"->"master""refs/tags/some-tag"->"refs/tags/some-tag"
tag, the providedrefis returned unchanged.As with
qualifying a ref, unqualifying a ref may produce incorrect results when provided a ref that looks fully- or partially-qualified but actually isn't. For example, if the head in the second example above was actually"heads/master"(meaning its fully-qualified name would be"refs/heads/heads/master"), the unqualified name"master"would be incorrect.- Parameters:
ref- the ref to unqualify, which may be fully- or partially-qualified- Returns:
- an unqualified ref according to this pattern
- Throws:
IllegalArgumentException- if the providedrefis empty or blankNullPointerException- if the providedrefisnull
-
defaultSort
Retrieves the default sort flag, to be applied to refs when no more-specific sort is desired (or makes sense).- Returns:
- the default sort
-