public enum GitRefPattern extends Enum<GitRefPattern>
| Enum Constant and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
defaultSort()
Retrieves the default sort flag, to be applied to refs when no more-specific sort is desired (or makes sense).
|
String[] |
getComponents()
Retrieves the components that make up this pattern's
path. |
String |
getPath()
Retrieves the path under the
.git directory containing all refs for this pattern. |
String |
getRefspec()
Retrieves a non-force refspec for this pattern.
|
String |
getRefspec(boolean force)
Retrieves a refspec for this pattern.
|
List<String> |
getSearchOrder(String ref)
Applies the git precedence ordering for the provided ref, constrained by this pattern, to produce an ordered list
of search candidates.
|
String |
qualify(String ref)
Qualifies the provided
ref according this pattern. |
String |
sort(com.atlassian.bitbucket.repository.RefOrder order)
Retrieves a flag that may be provided to the
git rev-list --sort= option to sort refs in the specified
order. |
String |
unqualify(String ref)
Unqualifies the provided
ref according to this pattern. |
static GitRefPattern |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static GitRefPattern[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final GitRefPattern HEADS
public static final GitRefPattern PULL_REQUESTS
public static final GitRefPattern REMOTES
public static final GitRefPattern TAGS
public static GitRefPattern[] values()
for (GitRefPattern c : GitRefPattern.values()) System.out.println(c);
public static GitRefPattern valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is null@Nonnull public String[] getComponents()
path.@Nonnull public String getPath()
.git directory containing all refs for this pattern.
Note: Paths returned from this method will always end with a trailing /.
@Nonnull public String getRefspec()
HEADS, the
refspec will be refs/heads/*:refs/heads/*.@Nonnull public String getRefspec(boolean force)
+ 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, for HEADS, the refspec will be +refs/heads/*:refs/heads/* if
force is true, and refs/heads/*:refs/heads/* otherwise.force - true for a forced update@Nonnull public List<String> getSearchOrder(@Nonnull String ref)
.git
directory in the same order git would search them.ref - the ref for which to build a search orderIllegalArgumentException - if the provided ref is empty or blankNullPointerException - if the provided ref is null@Nonnull public String qualify(@Nonnull String ref)
ref according this pattern. The returned value is suitable for use as a ref's
ID.
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 the HEADS pattern, 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".
ref - the ref to qualify, which may be fully- or partially-qualifiedIllegalArgumentException - if the provided ref is empty or blankNullPointerException - if the provided ref is nullpublic String sort(@Nullable com.atlassian.bitbucket.repository.RefOrder order)
git rev-list --sort= option to sort refs in the specified
order.order - the order to apply to refsgit rev-list --sort= flag for producing the specified order@Nonnull public String unqualify(@Nonnull String ref)
ref according to this pattern. The returned value is suitable for use as a
ref's display ID.
This process is the logical negation of qualifying a ref. It removes the path for
this pattern from the provided ref if it is present. If the provided ref is partially-qualified,
the partial qualification is removed.
Examples, using the HEADS pattern:
"refs/heads/master" -> "master""heads/master" -> "master""master" -> "master""refs/tags/some-tag" -> "refs/tags/some-tag"tag, the provided ref is 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.
ref - the ref to unqualify, which may be fully- or partially-qualifiedIllegalArgumentException - if the provided ref is empty or blankNullPointerException - if the provided ref is nullprotected String defaultSort()
Copyright © 2019 Atlassian. All rights reserved.