Skip to content

Commit 0a59bcf

Browse files
committed
Add IndraGitExtension#tagNames
1 parent 0bb1663 commit 0a59bcf

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

indra-git/src/main/java/net/kyori/indra/git/IndraGitExtension.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package net.kyori.indra.git;
2525

26+
import java.util.List;
2627
import org.eclipse.jgit.lib.ObjectId;
2728
import org.gradle.api.Action;
2829
import org.gradle.api.java.archives.Manifest;
@@ -99,6 +100,14 @@ default <V, P extends RepositoryValueSource.Parameters, S extends RepositoryValu
99100
*/
100101
@NotNull Provider<String> describe();
101102

103+
/**
104+
* Get the names of all tags in the repository.
105+
*
106+
* @return tag names, or an empty list if the project is not in a git repository or has no tags
107+
* @since 4.0.0
108+
*/
109+
@NotNull Provider<List<String>> tagNames();
110+
102111
/**
103112
* Get the name of the current branch.
104113
*

indra-git/src/main/java/net/kyori/indra/git/internal/IndraGitExtensionImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525

2626
import java.io.File;
2727
import java.io.IOException;
28+
import java.util.List;
2829
import javax.inject.Inject;
2930
import net.kyori.indra.git.IndraGitExtension;
3031
import net.kyori.indra.git.QueryBranch;
32+
import net.kyori.indra.git.QueryTags;
3133
import net.kyori.indra.git.RepositoryValueSource;
3234
import net.kyori.mammoth.Configurable;
3335
import org.eclipse.jgit.api.Git;
@@ -128,6 +130,12 @@ public static abstract class QueryDescribe extends RepositoryValueSource.Paramet
128130
return this.repositoryValue(QueryDescribe.class);
129131
}
130132

133+
@Override
134+
public @NotNull Provider<List<String>> tagNames() {
135+
return this.repositoryValue(QueryTags.Names.class)
136+
.map(list -> list.stream().map(Repository::shortenRefName).toList());
137+
}
138+
131139
@Override
132140
public @NotNull Provider<String> branchName() {
133141
return this.repositoryValue(QueryBranch.Name.class).map(Repository::shortenRefName);

0 commit comments

Comments
 (0)