Package org.eclipse.jgit.api
Class DescribeCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<java.lang.String>
-
- org.eclipse.jgit.api.DescribeCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.String>
public class DescribeCommand extends GitCommand<java.lang.String>
Given a commit, show the most recent tag that is reachable from a commit.- Since:
- 3.2
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DescribeCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
call()
Describes the specified commit.DescribeCommand
setTarget(java.lang.String rev)
Sets the commit to be described.DescribeCommand
setTarget(ObjectId target)
Sets the commit to be described.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
DescribeCommand
protected DescribeCommand(Repository repo)
- Parameters:
repo
-
-
-
Method Detail
-
setTarget
public DescribeCommand setTarget(ObjectId target) throws java.io.IOException
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.java.io.IOException
- a pack file or loose object could not be read.
-
setTarget
public DescribeCommand setTarget(java.lang.String rev) throws java.io.IOException, RefNotFoundException
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.java.io.IOException
- a pack file or loose object could not be read.
-
call
public java.lang.String call() throws GitAPIException
Describes the specified commit. Target defaults to HEAD if no commit was set explicitly.- Specified by:
call
in interfacejava.util.concurrent.Callable<java.lang.String>
- Specified by:
call
in classGitCommand<java.lang.String>
- Returns:
- if there's a tag that points to the commit being described, this
tag name is returned. Otherwise additional suffix is added to the
nearest tag, just like git-describe(1).
If none of the ancestors of the commit being described has any tags at all, then this method returns null, indicating that there's no way to describe this tag.
- Throws:
GitAPIException
- or subclass thereof when an error occurs
-
-