|
|
@ -48,6 +48,7 @@ import org.eclipse.jgit.api.errors.RefNotFoundException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.errors.MissingObjectException; |
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.Ref; |
|
|
|
import org.eclipse.jgit.lib.Ref; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
@ -107,7 +108,7 @@ public class DescribeCommand extends GitCommand<String> { |
|
|
|
* @throws IOException |
|
|
|
* @throws IOException |
|
|
|
* a pack file or loose object could not be read. |
|
|
|
* a pack file or loose object could not be read. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
DescribeCommand setTarget(ObjectId target) throws IOException { |
|
|
|
public DescribeCommand setTarget(ObjectId target) throws IOException { |
|
|
|
this.target = w.parseCommit(target); |
|
|
|
this.target = w.parseCommit(target); |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
@ -126,7 +127,8 @@ public class DescribeCommand extends GitCommand<String> { |
|
|
|
* @throws IOException |
|
|
|
* @throws IOException |
|
|
|
* a pack file or loose object could not be read. |
|
|
|
* a pack file or loose object could not be read. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
DescribeCommand setTarget(String rev) throws IOException, RefNotFoundException { |
|
|
|
public DescribeCommand setTarget(String rev) throws IOException, |
|
|
|
|
|
|
|
RefNotFoundException { |
|
|
|
ObjectId id = repo.resolve(rev); |
|
|
|
ObjectId id = repo.resolve(rev); |
|
|
|
if (id == null) |
|
|
|
if (id == null) |
|
|
|
throw new RefNotFoundException(MessageFormat.format(JGitText.get().refNotResolved, rev)); |
|
|
|
throw new RefNotFoundException(MessageFormat.format(JGitText.get().refNotResolved, rev)); |
|
|
@ -134,14 +136,16 @@ public class DescribeCommand extends GitCommand<String> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Describes the specified commit. |
|
|
|
* Describes the specified commit. Target defaults to HEAD if no commit was |
|
|
|
|
|
|
|
* set explicitly. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return if there's a tag that points to the commit being described, this tag name |
|
|
|
* @return if there's a tag that points to the commit being described, this |
|
|
|
* is returned. Otherwise additional suffix is added to the nearest tag, just |
|
|
|
* tag name is returned. Otherwise additional suffix is added to the |
|
|
|
* like git-describe(1). |
|
|
|
* nearest tag, just like git-describe(1). |
|
|
|
* <p/> |
|
|
|
* <p/> |
|
|
|
* If none of the ancestors of the commit being described has any tags at all, |
|
|
|
* If none of the ancestors of the commit being described has any |
|
|
|
* then this method returns null, indicating that there's no way to describe this tag. |
|
|
|
* tags at all, then this method returns null, indicating that |
|
|
|
|
|
|
|
* there's no way to describe this tag. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String call() throws GitAPIException { |
|
|
|
public String call() throws GitAPIException { |
|
|
@ -149,7 +153,7 @@ public class DescribeCommand extends GitCommand<String> { |
|
|
|
checkCallable(); |
|
|
|
checkCallable(); |
|
|
|
|
|
|
|
|
|
|
|
if (target == null) |
|
|
|
if (target == null) |
|
|
|
throw new IllegalArgumentException(JGitText.get().targetIsNotSet); |
|
|
|
setTarget(Constants.HEAD); |
|
|
|
|
|
|
|
|
|
|
|
Map<ObjectId, Ref> tags = new HashMap<ObjectId, Ref>(); |
|
|
|
Map<ObjectId, Ref> tags = new HashMap<ObjectId, Ref>(); |
|
|
|
|
|
|
|
|
|
|
|