Package org.eclipse.jgit.api
Class DescribeCommand
Given a commit, show the most recent tag that is reachable from a commit.
- Since:
- 3.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Whether to show a uniquely abbreviated commit hash as a fallback or not.private boolean
Whether to always use long output format or not.private List
<FileNameMatcher> Pattern matchers to be applied to tags under consideration.private int
How many tags we'll consider as candidates.private final Comparator
<Ref> private RevCommit
Commit to describe.private boolean
Whether to use all refs in the refs/ namespaceprivate boolean
Whether to use all tags (incl.private final RevWalk
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DescribeCommand
(Repository repo) Constructor for DescribeCommand. -
Method Summary
Modifier and TypeMethodDescriptioncall()
private boolean
filterLightweightTags
(Ref ref) Whether we use lightweight tags or not for describe Candidatesprivate String
formatRefName
(String name) Removes the refs/ or refs/tags prefix from tag namesgetBestMatch
(List<Ref> tags) private ObjectId
private String
longDescription
(Ref tag, int depth, ObjectId tip) setAll
(boolean all) Instead of using only the annotated tags, use any ref found in refs/ namespace.setAlways
(boolean always) Always describe the commit by eventually falling back to a uniquely abbreviated commit hash if no other name matches.setLong
(boolean longDesc) Determine whether always to use the long format or not.Sets one or moreglob(7)
patterns that tags must match to be considered.setTags
(boolean tags) Instead of using only the annotated tags, use any tag found in refs/tags namespace.Sets the commit to be described.Sets the commit to be described.Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
w
-
target
Commit to describe. -
maxCandidates
private int maxCandidatesHow many tags we'll consider as candidates. This can only go up to the number of flags JGit can support in a walk, which is 24. -
longDesc
private boolean longDescWhether to always use long output format or not. -
matchers
Pattern matchers to be applied to tags under consideration. -
useAll
private boolean useAllWhether to use all refs in the refs/ namespace -
useTags
private boolean useTagsWhether to use all tags (incl. lightweight) or not. -
always
private boolean alwaysWhether to show a uniquely abbreviated commit hash as a fallback or not. -
TAG_TIE_BREAKER
-
-
Constructor Details
-
DescribeCommand
Constructor for DescribeCommand.- Parameters:
repo
- theRepository
-
-
Method Details
-
setTarget
Sets the commit to be described.- Parameters:
target
- A non-null object ID to be described.- Returns:
this
- Throws:
MissingObjectException
- the supplied commit does not exist.IncorrectObjectTypeException
- the supplied id is not a commit or an annotated tag.IOException
- a pack file or loose object could not be read.
-
setTarget
Sets the commit to be described.- Parameters:
rev
- Commit ID, tag, branch, ref, etc. SeeRepository.resolve(String)
for allowed syntax.- Returns:
this
- Throws:
IncorrectObjectTypeException
- the supplied id is not a commit or an annotated tag.RefNotFoundException
- the given rev didn't resolve to any object.IOException
- a pack file or loose object could not be read.
-
setLong
Determine whether always to use the long format or not. When set totrue
the long format is used even the commit matches a tag.- Parameters:
longDesc
-true
if always the long format should be used.- Returns:
this
- Since:
- 4.0
- See Also:
-
setAll
Instead of using only the annotated tags, use any ref found in refs/ namespace. This option enables matching any known branch, remote-tracking branch, or lightweight tag.- Parameters:
all
-true
enables matching any ref found in refs/ like setting option --all in c git- Returns:
this
- Since:
- 5.10
-
setTags
Instead of using only the annotated tags, use any tag found in refs/tags namespace. This option enables matching lightweight (non-annotated) tags or not.- Parameters:
tags
-true
enables matching lightweight (non-annotated) tags like setting option --tags in c git- Returns:
this
- Since:
- 5.0
-
setAlways
Always describe the commit by eventually falling back to a uniquely abbreviated commit hash if no other name matches.- Parameters:
always
-true
enables falling back to a uniquely abbreviated commit hash- Returns:
this
- Since:
- 5.4
-
longDescription
- Throws:
IOException
-
setMatch
Sets one or moreglob(7)
patterns that tags must match to be considered. If multiple patterns are provided, tags only need match one of them.- Parameters:
patterns
- theglob(7)
pattern or patterns- Returns:
this
- Throws:
InvalidPatternException
- if the pattern passed in was invalid.- Since:
- 4.9
- See Also:
-
getBestMatch
-
getObjectIdFromRef
- Throws:
JGitInternalException
-
call
Execute the command
Describes the specified commit. Target defaults to HEAD if no commit was set explicitly.
- Specified by:
call
in interfaceCallable<String>
- Specified by:
call
in classGitCommand<String>
- Throws:
GitAPIException
-
formatRefName
Removes the refs/ or refs/tags prefix from tag names- Parameters:
name
- the name of the tag- Returns:
- the tag name with its prefix removed
-
filterLightweightTags
Whether we use lightweight tags or not for describe Candidates- Parameters:
ref
- reference under inspection- Returns:
- true if it should be used for describe or not regarding
useTags
-