Package org.eclipse.jgit.api
Class DescribeCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<String>
-
- org.eclipse.jgit.api.DescribeCommand
-
public class DescribeCommand extends GitCommand<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 protectedDescribeCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcall()Describes the specified commit.DescribeCommandsetTarget(String rev)Sets the commit to be described.DescribeCommandsetTarget(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 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.IOException- a pack file or loose object could not be read.
-
setTarget
public DescribeCommand setTarget(String rev) throws 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.IOException- a pack file or loose object could not be read.
-
call
public String call() throws GitAPIException
Describes the specified commit. Target defaults to HEAD if no commit was set explicitly.- Specified by:
callin interfaceCallable<String>- Specified by:
callin classGitCommand<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
-
-