Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describeTagPattern-Example in docs suggests behaviour not actually implemented #244

Open
cboehme opened this issue Mar 10, 2023 · 0 comments
Assignees

Comments

@cboehme
Copy link
Contributor

cboehme commented Mar 10, 2023

The readme has an example showing how to build a version from describe tag pattern groups:

<ref type="branch">
    <pattern>main</pattern>
    <describeTagPattern><![CDATA[v(?<version>.*)]]></describeTagPattern>
    <version>${describe.tag.version}-SNAPSHOT</version>
</ref>

This looks like as if the placeholder describe.tag.version contains the text matched by the regex in <describeTagPattern>, but actually the placeholder contains the version as matched by the fixed regex that is used to generate describe.tag.version.*placeholders.

This is because the method generateGlobalPlaceholdersMap() first adds the groups created by the describeTagPattern to the placeholders map and than adds the describe.tag.version.*placeholders which results in description.tag.version being overwritten:

for (String groupName : patternGroups(gitSituation.getDescribeTagPattern())) {
    Lazy<String> groupValue = Lazy.by(() -> describeTagPatternValues.get().get(groupName));
    placeholderMap.put("describe.tag." + groupName, groupValue);
    placeholderMap.put("describe.tag." + groupName + ".slug", Lazy.by(() -> slugify(groupValue.get())));
 }

final Lazy<Matcher> descriptionTagVersionMatcher = Lazy.by(() -> matchVersion(descriptionTag.get()));

placeholderMap.put("describe.tag.version", Lazy.by(() -> requireNonNullElse(descriptionTagVersionMatcher.get().group("version"), "0.0.0")));

Note, that the describe.tag.version.slug placeholder still contains the text matched by the describe tag pattern.

Im am not sure how to fix this. Obviously, the easiest solution would be to change the example to use a different placeholder which does not collide with the describe.tag.version.* placeholders. However, I think a better solution would be to use the version matched by the describe tag pattern as the starting point for generating the describe.tag.version.* placeholders (I hope this makes sense).

@qoomon qoomon self-assigned this Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants