Skip to content

Commit

Permalink
fix: ignore invalid version tags when computing next tag
Browse files Browse the repository at this point in the history
  • Loading branch information
loicrouchon committed Feb 13, 2024
1 parent 6a9bdab commit 970dc50
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/releaser/src/main/java/releaser/GitRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Pattern;

class GitRepository {

private static final Pattern VERSION_TAG_PATTERN = Pattern.compile("^v[0-9]+(:?\\.[0-9]+)*$");

private final Git git;
protected final BranchingModel branchingModel;
protected String currentBranch;
Expand Down Expand Up @@ -121,6 +124,7 @@ public Optional<Version> latestReleaseBranchVersion(Version baseVersion) {

public Optional<Version> latestTaggedVersionForBaseVersion(Version baseVersion) {
return tags(baseVersion).stream()
.filter(tag -> VERSION_TAG_PATTERN.matcher(tag).matches())
.map(tag -> tag.replaceFirst("^v", ""))
.max(Version::compare)
.map(Version::parse);
Expand Down

0 comments on commit 970dc50

Please sign in to comment.