diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2020-12-08 15:45:35 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-08 22:20:46 +0100 |
commit | e3ac56e2d0477b10993f2895f7a1a7cf1c40a3d5 (patch) | |
tree | e6b1a9f600322316b8c6ec742c23065c2ea60bbc /org.eclipse.jgit.test/tst/org | |
parent | 29e1270768f217f7c8471d771d90ff43135d7c26 (diff) | |
download | jgit-e3ac56e2d0477b10993f2895f7a1a7cf1c40a3d5.tar.gz jgit-e3ac56e2d0477b10993f2895f7a1a7cf1c40a3d5.zip |
TagCommand: propagate NO_CHANGE information
Some clients may wish to allow NO_CHANGE lightweight tag updates
without setting the force flag. (For instance EGit does so.)
Command-line git does not allow this.
Propagate the RefUpdate result via the RefAlreadyExistsException.
That way a client has the possibility to catch it and check the
failure reason without having to parse the exception message, and
take appropriate action, like ignoring the exception on NO_CHANGE.
Change-Id: I60e7a15a3c309db4106cab87847a19b6d24866f6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java index 21de1d4517..99034174ba 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java @@ -25,6 +25,7 @@ import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.api.errors.RefAlreadyExistsException; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.Ref; +import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; @@ -133,9 +134,11 @@ public class TagCommandTest extends RepositoryTestCase { .setAnnotated(false).call(); assertEquals(commit.getId(), tagRef.getObjectId()); // Without force, we want to get a RefAlreadyExistsException - assertThrows(RefAlreadyExistsException.class, + RefAlreadyExistsException e = assertThrows( + RefAlreadyExistsException.class, () -> git.tag().setObjectId(commit).setName("tag") .setAnnotated(false).call()); + assertEquals(RefUpdate.Result.NO_CHANGE, e.getUpdateResult()); // With force the call should work assertEquals(commit.getId(), git.tag().setObjectId(commit).setName("tag") |