Skip to content

Commit b81c4d8

Browse files
committed
Use value from entry set when iterating over tags.
Previously the tag ref was re-fetched from the repository when iterating over the tags in getTagsOnCommit.
1 parent f5a2785 commit b81c4d8

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/main/java/hudson/plugins/git/GitAPI.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -979,16 +979,16 @@ public Repository getRepository() throws IOException {
979979
return new FileRepository(new File(workspace.getRemote(), Constants.DOT_GIT));
980980
}
981981

982-
public List<Tag> getTagsOnCommit(String revName) throws GitException, IOException {
983-
Repository db = getRepository();
984-
ObjectId commit = db.resolve(revName);
985-
List<Tag> ret = new ArrayList<Tag>();
982+
public List<Tag> getTagsOnCommit(final String revName) throws GitException,
983+
IOException {
984+
final Repository db = getRepository();
985+
final ObjectId commit = db.resolve(revName);
986+
final List<Tag> ret = new ArrayList<Tag>();
986987

987988
for (final Map.Entry<String, Ref> tag : db.getTags().entrySet()) {
988-
989-
Ref ref = db.getTags().get( tag.getKey() );
990-
if( ref.getObjectId().equals(commit) )
991-
ret.add( new Tag( tag.getKey(), ref.getObjectId() ) );
989+
final ObjectId tagId = tag.getValue().getObjectId();
990+
if (commit.equals(tagId))
991+
ret.add(new Tag(tag.getKey(), tagId));
992992
}
993993
return ret;
994994
}

0 commit comments

Comments
 (0)