You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/07/25 18:08:46 UTC
[maven-scm] branch master updated: Close RevWalk after usage
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm.git
The following commit(s) were added to refs/heads/master by this push:
new e570d52c9 Close RevWalk after usage
e570d52c9 is described below
commit e570d52c91c708490a33d917cc8a48bc0d80f3e9
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Jul 25 08:44:30 2022 +0200
Close RevWalk after usage
Remove deprecated method RefDatabase.getRefs(String)
This closes #157
---
.../scm/provider/git/jgit/command/JGitUtils.java | 26 +++++++++++-----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
index baab4ff10..74039e6aa 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
@@ -73,7 +73,6 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import static org.eclipse.jgit.lib.Constants.R_TAGS;
@@ -543,23 +542,24 @@ public class JGitUtils
*/
public static List<String> getTags( Repository repo, RevCommit commit ) throws IOException
{
- Map<String, Ref> refList = repo.getRefDatabase().getRefs( R_TAGS );
+ List<Ref> refList = repo.getRefDatabase().getRefsByPrefix( R_TAGS );
- RevWalk revWalk = new RevWalk( repo );
-
- ObjectId commitId = commit.getId();
- List<String> result = new ArrayList<>();
-
- for ( Map.Entry<String, Ref> refEntry : refList.entrySet() )
+ try ( RevWalk revWalk = new RevWalk( repo ) )
{
- ObjectId tagId = refEntry.getValue().getObjectId();
- RevCommit tagCommit = revWalk.parseCommit( tagId );
- if ( tagCommit != null && commitId.equals( tagCommit.getId() ) )
+ ObjectId commitId = commit.getId();
+ List<String> result = new ArrayList<>();
+
+ for ( Ref ref : refList )
{
- result.add( refEntry.getKey() );
+ ObjectId tagId = ref.getObjectId();
+ RevCommit tagCommit = revWalk.parseCommit( tagId );
+ if ( commitId.equals( tagCommit.getId() ) )
+ {
+ result.add( ref.getName().substring( R_TAGS.length() ) );
+ }
}
+ return result;
}
- return result;
}
}