@@ -52,27 +52,31 @@ public JGitCommon(LoggerBridge log) {
5252 this .log = log ;
5353 }
5454
55- public Collection <String > getTags (Repository repo , final ObjectId headId ) throws GitAPIException {
55+ public Collection <String > getTags (Repository repo , final ObjectId objectId ) throws GitAPIException {
5656 try (Git git = Git .wrap (repo )) {
5757 try (RevWalk walk = new RevWalk (repo )) {
58- Collection <String > tags = getTags (git , headId , walk );
58+ Collection <String > tags = getTags (git , objectId , walk );
5959 walk .dispose ();
6060 return tags ;
6161 }
6262 }
6363 }
6464
65- private Collection <String > getTags (final Git git , final ObjectId headId , final RevWalk finalWalk ) throws GitAPIException {
65+ private Collection <String > getTags (final Git git , final ObjectId objectId , final RevWalk finalWalk ) throws GitAPIException {
6666 List <Ref > tagRefs = git .tagList ().call ();
6767 Collection <Ref > tagsForHeadCommit = Collections2 .filter (tagRefs , new Predicate <Ref >() {
68- @ Override public boolean apply ( Ref tagRef ) {
69- boolean lightweightTag = tagRef . getObjectId (). equals ( headId );
68+ @ Override
69+ public boolean apply ( Ref tagRef ) {
7070 try {
71- // TODO make this configurable (most users shouldn't really care too much what kind of tag it is though)
72- return lightweightTag || finalWalk .parseTag (tagRef .getObjectId ()).getObject ().getId ().equals (headId ); // or normal tag
73- } catch (IOException e ) {
74- return false ;
71+ final RevCommit tagCommit = finalWalk .parseCommit (tagRef .getObjectId ());
72+ final RevCommit objectCommit = finalWalk .parseCommit (objectId );
73+ if (finalWalk .isMergedInto (objectCommit , tagCommit )) {
74+ return true ;
75+ }
76+ } catch (Exception ignored ) {
77+ log .debug ("Failed while getTags [{}] -- " , tagRef , ignored );
7578 }
79+ return false ;
7680 }
7781 });
7882 Collection <String > tags = Collections2 .transform (tagsForHeadCommit , new Function <Ref , String >() {
0 commit comments