diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-04-06 05:34:00 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2012-04-06 05:34:00 -0400 |
commit | e951b407fa6e028ef07c73ea7be8bbd19fe070f9 (patch) | |
tree | 571ceaed349ca19d44b72d5fab322b6e2101eb58 /org.eclipse.jgit | |
parent | fcacfdeaf7c73745497dfc88c7acb59b72ac5898 (diff) | |
parent | fd53b454f230d70a319f32f6d5524268e0338ca6 (diff) | |
download | jgit-e951b407fa6e028ef07c73ea7be8bbd19fe070f9.tar.gz jgit-e951b407fa6e028ef07c73ea7be8bbd19fe070f9.zip |
Merge "Fix broken TagCommand API"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java | 16 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java | 11 |
2 files changed, 12 insertions, 15 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java index ec199c37ab..c1ae88731f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ListTagCommand.java @@ -53,7 +53,6 @@ import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevTag; import org.eclipse.jgit.revwalk.RevWalk; /** @@ -62,7 +61,7 @@ import org.eclipse.jgit.revwalk.RevWalk; * @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html" * >Git documentation about Tag</a> */ -public class ListTagCommand extends GitCommand<List<RevTag>> { +public class ListTagCommand extends GitCommand<List<Ref>> { /** * @param repo @@ -76,25 +75,24 @@ public class ListTagCommand extends GitCommand<List<RevTag>> { * upon internal failure * @return the tags available */ - public List<RevTag> call() throws JGitInternalException { + public List<Ref> call() throws JGitInternalException { checkCallable(); Map<String, Ref> refList; - List<RevTag> tags = new ArrayList<RevTag>(); + List<Ref> tags = new ArrayList<Ref>(); RevWalk revWalk = new RevWalk(repo); try { refList = repo.getRefDatabase().getRefs(Constants.R_TAGS); for (Ref ref : refList.values()) { - RevTag tag = revWalk.parseTag(ref.getObjectId()); - tags.add(tag); + tags.add(ref); } } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } finally { revWalk.release(); } - Collections.sort(tags, new Comparator<RevTag>() { - public int compare(RevTag o1, RevTag o2) { - return o1.getTagName().compareTo(o2.getTagName()); + Collections.sort(tags, new Comparator<Ref>() { + public int compare(Ref o1, Ref o2) { + return o1.getName().compareTo(o2.getName()); } }); setCallable(false); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java index d5196a3e1f..30d548cd64 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/TagCommand.java @@ -54,13 +54,13 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectInserter; import org.eclipse.jgit.lib.PersonIdent; +import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.TagBuilder; import org.eclipse.jgit.revwalk.RevObject; -import org.eclipse.jgit.revwalk.RevTag; import org.eclipse.jgit.revwalk.RevWalk; /** @@ -71,7 +71,7 @@ import org.eclipse.jgit.revwalk.RevWalk; * @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html" * >Git documentation about Tag</a> */ -public class TagCommand extends GitCommand<RevTag> { +public class TagCommand extends GitCommand<Ref> { private RevObject id; private String name; @@ -97,7 +97,7 @@ public class TagCommand extends GitCommand<RevTag> { * class should only be used for one invocation of the command (means: one * call to {@link #call()}) * - * @return a {@link RevTag} object representing the successful tag + * @return a {@link Ref} a ref pointing to a tag * @throws NoHeadException * when called on a git repo without a HEAD reference * @throws JGitInternalException @@ -106,7 +106,7 @@ public class TagCommand extends GitCommand<RevTag> { * {@link Exception#getCause()}. Expect only * {@code IOException's} to be wrapped. */ - public RevTag call() throws JGitInternalException, + public Ref call() throws JGitInternalException, ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException { checkCallable(); @@ -140,7 +140,6 @@ public class TagCommand extends GitCommand<RevTag> { RevWalk revWalk = new RevWalk(repo); try { - RevTag revTag = revWalk.parseTag(tagId); String refName = Constants.R_TAGS + newTag.getTag(); RefUpdate tagRef = repo.updateRef(refName); tagRef.setNewObjectId(tagId); @@ -150,7 +149,7 @@ public class TagCommand extends GitCommand<RevTag> { switch (updateResult) { case NEW: case FORCED: - return revTag; + return repo.getRef(refName); case LOCK_FAILURE: throw new ConcurrentRefUpdateException( JGitText.get().couldNotLockHEAD, |