@@ -200,17 +200,17 @@ public void testExceptions() throws Exception {
200
200
private void testExceptionThrowingNoMock (Exception testException , Method m , Object [] params ) throws Exception {
201
201
try {
202
202
m .invoke (vcs , params );
203
- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
203
+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
204
204
fail ();
205
205
}
206
206
} catch (InvocationTargetException e ) {
207
- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
207
+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
208
208
// InvocationTargetException <- EVCSException <- GitAPIException
209
209
assertTrue (e .getCause ().getCause ().getClass ().isAssignableFrom (testException .getClass ()));
210
210
assertTrue (e .getCause ().getMessage ().contains (testException .getMessage ()));
211
211
}
212
212
} catch (Exception e ) {
213
- if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked (vcs )) {
213
+ if (!m .getName ().equals ("checkout" ) && wasGetLocalGitInvoked ()) {
214
214
fail ();
215
215
}
216
216
}
@@ -224,7 +224,7 @@ private void testExceptionThrowing(Exception testException, Method m, Object[] p
224
224
225
225
}
226
226
227
- private Boolean wasGetLocalGitInvoked (IVCS vcs ) throws Exception {
227
+ private Boolean wasGetLocalGitInvoked () throws Exception {
228
228
try {
229
229
Mockito .verify (git ).getLocalGit (mockedLWC );
230
230
return true ;
@@ -303,7 +303,7 @@ public void testGetTagsUnannotated() throws Exception {
303
303
assertEquals (tag .getRelatedCommit (), vcs .getHeadCommit (null ));
304
304
}
305
305
306
- public void createUnannotatedTag (String branchName , String tagName , String revisionToTag ) throws Exception {
306
+ public VCSTag createUnannotatedTag (String branchName , String tagName , String revisionToTag ) throws Exception {
307
307
try (IVCSLockedWorkingCopy wc = localVCSRepo .getVCSLockedWorkingCopy ();
308
308
Git localGit = git .getLocalGit (wc );
309
309
Repository gitRepo = localGit .getRepository ();
@@ -327,6 +327,8 @@ public void createUnannotatedTag(String branchName, String tagName, String revis
327
327
.setRemote ("origin" )
328
328
.setCredentialsProvider (git .getCredentials ())
329
329
.call ();
330
+ return new VCSTag (tagName , null , null , revisionToTag == null ? vcs .getHeadCommit (branchName )
331
+ : git .getVCSCommit (commitToTag ));
330
332
}
331
333
}
332
334
@@ -385,5 +387,18 @@ public void testIsRevisionTaggedUnannotated() throws Exception {
385
387
assertTrue (vcs .isRevisionTagged (c2 .getRevision ()));
386
388
assertFalse (vcs .isRevisionTagged (c3 .getRevision ()));
387
389
}
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
+ }
388
403
}
389
404
0 commit comments