Skip to content

Commit

Permalink
Add names of versions parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore committed Jul 3, 2023
1 parent 7ba8f2f commit d4226ff
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>org.octopusden.octopus.releng</groupId>
<artifactId>versions-api</artifactId>
<version>2.0.4</version>
<version>2.0.8</version>
<exclusions>
<exclusion>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import org.octopusden.octopus.releng.dto.ComponentInfo;
import org.octopusden.octopus.releng.dto.JiraComponent;
import org.octopusden.octopus.releng.dto.JiraComponentVersion;
import org.octopusden.releng.versions.IVersionInfo;
import org.octopusden.releng.versions.KotlinVersionFormatter;
import org.octopusden.releng.versions.NumericVersion;
import org.octopusden.releng.versions.VersionFormatter;
import org.octopusden.octopus.releng.utils.VersionNamesHelper;
import org.octopusden.releng.versions.*;
import org.apache.commons.lang3.StringUtils;

public class JiraComponentVersionFormatter {
private final VersionFormatter versionFormatter = new KotlinVersionFormatter();
private final VersionFormatter versionFormatter = new KotlinVersionFormatter(VersionNamesHelper.INSTANCE);
private final NumericVersionFactory numericVersionFactory = new NumericVersionFactory(VersionNamesHelper.INSTANCE);

public String getReleaseVersion(JiraComponentVersion jiraComponentVersion) {
return formatReleaseVersionFormat(jiraComponentVersion, jiraComponentVersion.getVersion());
Expand Down Expand Up @@ -98,22 +97,22 @@ public boolean matchesRCVersionFormat(JiraComponentVersion jiraComponentVersion,

public String formatMajorVersionFormat(JiraComponentVersion jiraComponentVersion, String version) {
String majorVersionFormat = jiraComponentVersion.getComponent().getComponentVersionFormat().getMajorVersionFormat();
return format(jiraComponentVersion, majorVersionFormat, NumericVersion.parse(version));
return format(jiraComponentVersion, majorVersionFormat, numericVersionFactory.create(version));
}

public String formatReleaseVersionFormat(JiraComponentVersion jiraComponentVersion, String version) {
String releaseVersionFormat = jiraComponentVersion.getComponent().getComponentVersionFormat().getReleaseVersionFormat();
return format(jiraComponentVersion, releaseVersionFormat, NumericVersion.parse(version));
return format(jiraComponentVersion, releaseVersionFormat, numericVersionFactory.create(version));
}

public String formatBuildVersionFormat(JiraComponentVersion jiraComponentVersion, String version) {
String buildVersionFormat = getBuildVersionFormat(jiraComponentVersion);
return format(jiraComponentVersion, buildVersionFormat, NumericVersion.parse(version));
return format(jiraComponentVersion, buildVersionFormat, numericVersionFactory.create(version));
}

public String formatLineVersionFormat(JiraComponentVersion jiraComponentVersion, String version) {
String lineVersionFormat = getLineVersionFormat(jiraComponentVersion);
return format(jiraComponentVersion, lineVersionFormat, NumericVersion.parse(version));
return format(jiraComponentVersion, lineVersionFormat, numericVersionFactory.create(version));
}

public String getBuildVersionFormat(JiraComponentVersion jiraComponentVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.octopusden.octopus.releng.dto.ComponentVersion;
import org.octopusden.octopus.releng.dto.JiraComponent;
import org.octopusden.octopus.releng.dto.JiraComponentVersion;
import org.octopusden.octopus.releng.utils.VersionNamesHelper;
import org.octopusden.releng.versions.ComponentVersionFormat;
import org.octopusden.releng.versions.KotlinVersionFormatter;
import org.octopusden.releng.versions.VersionFormatter;
Expand Down Expand Up @@ -104,7 +105,7 @@ private JiraComponentVersion deserializeFromRequestString(String component) {

ComponentVersionFormat versionFormat = ComponentVersionFormat.create(majorVersionFormat, releaseVersionFormat);

VersionFormatter versionFormatter = new KotlinVersionFormatter();
VersionFormatter versionFormatter = new KotlinVersionFormatter(VersionNamesHelper.INSTANCE);
if (!versionFormatter.matchesFormat(versionFormat.getReleaseVersionFormat(), releaseVersion)) {
throw new IllegalArgumentException(String.format("In module %s unable to parse version %s. Should be in format %s", projectKey, releaseVersion,
releaseVersionFormat));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.octopusden.octopus.releng.JiraComponentVersionFormatter;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.octopusden.octopus.releng.utils.VersionNamesHelper;
import org.octopusden.releng.versions.VersionNames;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.octopusden.octopus.releng.utils;

import org.octopusden.releng.versions.VersionNames;

public final class VersionNamesHelper {

public static final VersionNames INSTANCE = new VersionNames(
System.getProperty("serviceBranch"),
System.getProperty("service"),
System.getProperty("minor"));

private VersionNamesHelper() {
}
}

0 comments on commit d4226ff

Please sign in to comment.