@@ -200,17 +200,17 @@ public void testExceptions() throws Exception {
200200 private void testExceptionThrowingNoMock (Exception testException , Method m , Object [] params ) throws Exception {
201201 try {
202202 m .invoke (vcs , params );
203- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
203+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
204204 fail ();
205205 }
206206 } catch (InvocationTargetException e ) {
207- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
207+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
208208 // InvocationTargetException <- EVCSException <- GitAPIException
209209 assertTrue (e .getCause ().getCause ().getClass ().isAssignableFrom (testException .getClass ()));
210210 assertTrue (e .getCause ().getMessage ().contains (testException .getMessage ()));
211211 }
212212 } catch (Exception e ) {
213- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
213+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
214214 fail ();
215215 }
216216 }
@@ -224,7 +224,7 @@ private void testExceptionThrowing(Exception testException, Method m, Object[] p
224224
225225 }
226226
227- private Boolean wasGetLocalGitInvoked (IVCS vcs ) throws Exception {
227+ private Boolean wasGetLocalGitInvoked () throws Exception {
228228 try {
229229 Mockito .verify (git ).getLocalGit (mockedLWC );
230230 return true ;
@@ -303,7 +303,7 @@ public void testGetTagsUnannotated() throws Exception {
303303 assertEquals (tag .getRelatedCommit (), vcs .getHeadCommit (null ));
304304 }
305305
306- public void createUnannotatedTag (String branchName , String tagName , String revisionToTag ) throws Exception {
306+ public VCSTag createUnannotatedTag (String branchName , String tagName , String revisionToTag ) throws Exception {
307307 try (IVCSLockedWorkingCopy wc = localVCSRepo .getVCSLockedWorkingCopy ();
308308 Git localGit = git .getLocalGit (wc );
309309 Repository gitRepo = localGit .getRepository ();
@@ -327,6 +327,8 @@ public void createUnannotatedTag(String branchName, String tagName, String revis
327327 .setRemote ("origin" )
328328 .setCredentialsProvider (git .getCredentials ())
329329 .call ();
330+ return new VCSTag (tagName , null , null , revisionToTag == null ? vcs .getHeadCommit (branchName )
331+ : git .getVCSCommit (commitToTag ));
330332 }
331333 }
332334
@@ -385,5 +387,18 @@ public void testIsRevisionTaggedUnannotated() throws Exception {
385387 assertTrue (vcs .isRevisionTagged (c2 .getRevision ()));
386388 assertFalse (vcs .isRevisionTagged (c3 .getRevision ()));
387389 }
390+
391+ @ Test
392+ public void testGetTagByNameUnannotated () throws Exception {
393+ vcs .setFileContent (null , FILE1_NAME , LINE_1 , FILE1_ADDED_COMMIT_MESSAGE );
394+ VCSCommit c2 = vcs .setFileContent (null , FILE1_NAME , LINE_2 , FILE1_CONTENT_CHANGED_COMMIT_MESSAGE + " " + LINE_2 );
395+ VCSCommit c3 = vcs .setFileContent (null , FILE1_NAME , LINE_3 , FILE1_CONTENT_CHANGED_COMMIT_MESSAGE + " " + LINE_3 );
396+
397+ VCSTag tag1 = createUnannotatedTag (null , TAG_NAME_1 , c2 .getRevision ());
398+ VCSTag tag2 = createUnannotatedTag (null , TAG_NAME_2 , c3 .getRevision ());
399+
400+ assertEquals (tag1 , vcs .getTagByName (TAG_NAME_1 ));
401+ assertEquals (tag2 , vcs .getTagByName (TAG_NAME_2 ));
402+ }
388403}
389404
0 commit comments