com.github.zafarkhaja.semver.Version.setPreReleaseVersion()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中com.github.zafarkhaja.semver.Version.setPreReleaseVersion()方法的一些代码示例,展示了Version.setPreReleaseVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.setPreReleaseVersion()方法的具体详情如下:
包路径:com.github.zafarkhaja.semver.Version
类名称:Version
方法名:setPreReleaseVersion

Version.setPreReleaseVersion介绍

[英]Sets the pre-release version.
[中]

代码示例

代码示例来源:origin: Graylog2/graylog2-server

private static com.github.zafarkhaja.semver.Version buildSemVer(int major, int minor, int patch, String preRelease, String buildMetadata) {
  com.github.zafarkhaja.semver.Version version = com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch);
  if (!isNullOrEmpty(preRelease)) {
    version = version.setPreReleaseVersion(preRelease);
  }
  if (!isNullOrEmpty(buildMetadata)) {
    version = version.setBuildMetadata(buildMetadata);
  }
  return version;
}

代码示例来源:origin: org.ajoberstar/semver-vcs-api

/**
 * Snapshot stage will always set the pre-release information to {@code SNAPSHOT}.
 * @return the snapshot stage
 */
public static Stage snapshotStage() {
  return new Stage("snapshot", (base, vcs) -> base.setPreReleaseVersion("SNAPSHOT"));
}

代码示例来源:origin: org.graylog2/graylog2-server

private static com.github.zafarkhaja.semver.Version buildSemVer(int major, int minor, int patch, String preRelease, String buildMetadata) {
  com.github.zafarkhaja.semver.Version version = com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch);
  if (!isNullOrEmpty(preRelease)) {
    version = version.setPreReleaseVersion(preRelease);
  }
  if (!isNullOrEmpty(buildMetadata)) {
    version = version.setBuildMetadata(buildMetadata);
  }
  return version;
}

代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump

public String nextPreReleaseVersion(final String releaseTag, final String releaseTagPattern) {
  if (releaseTag.matches(releaseTagPattern)) {
    final Pattern pattern = Pattern.compile(releaseTagPattern);
    final Matcher m = pattern.matcher(releaseTag);
    m.matches();
    Version v = Version.valueOf(m.group(0));
    if (!m.group(2).contains("-")) {
      v = v.incrementPatchVersion().setPreReleaseVersion("rc").incrementPreReleaseVersion();
    } else {
      v = v.incrementPreReleaseVersion();
    }
    return v.toString();
  }
  return StringUtils.EMPTY;
}

代码示例来源:origin: org.ajoberstar/semver-vcs-api

private static Version sanitizeStage(Version inferred, String stage, boolean fixed) {
  String[] rawIdents = inferred.getPreReleaseVersion().split("\\.");
  int rawEndIndex = getEndIndex(rawIdents, 0);
  int limit;
  if (stage.equals(rawIdents[0])) {
    limit = 2;
  } else if (!fixed) {
    if (rawIdents.length > 2 && stage.equals(rawIdents[2])) {
      limit = 4;
    } else {
      limit = 2;
    }
  } else {
    return Version.valueOf(inferred.getNormalVersion());
  }
  int endIndex = Math.min(rawEndIndex, limit);
  String[] validIdents = Arrays.copyOfRange(rawIdents, 0, endIndex);
  String preRelease = String.join(".", validIdents);
  if (preRelease == null || preRelease.isEmpty()) {
    return inferred;
  } else {
    return inferred.setPreReleaseVersion(preRelease);
  }
}

代码示例来源:origin: org.ajoberstar/semver-vcs-api

/**
 * Floating stages will behave as a fixed stage if the previous versions stage
 * either doesn't exist or has a lower precedence. If the previous has a higher
 * precedence, the pre-release information will be of the form
 * {@code <previous stage>.<previous count>.<stage name>.<incremented count>}.
 * @param name the name of the stage
 * @return a floating stage
 */
public static Stage floatingStage(String name) {
  return new Stage(name, (base, vcs) -> {
    Version sanitized = sanitizeStage(base, name, false);
    String[] prevStages = sanitized.getPreReleaseVersion().split("\\.");
    if (Arrays.binarySearch(prevStages, name) >= 0) {
      return sanitized.incrementPreReleaseVersion();
    } else if (name.compareTo(prevStages[0]) > 0) {
      return sanitized.setPreReleaseVersion(name).incrementPreReleaseVersion();
    } else {
      return sanitized.setPreReleaseVersion(sanitized.getPreReleaseVersion() + "." + name).incrementPreReleaseVersion();
    }
  });
}

代码示例来源:origin: org.ajoberstar/semver-vcs-api

/**
 * Fixed stages will always use pre-release information of the form
 * {@code <stage name>.<incremented count>}, where the count is always 1,
 * unless the previous version used the same stage. In that case the
 * count will be incremented from the previous.
 * @param name the name of the stage
 * @return a fixed stage
 */
public static Stage fixedStage(String name) {
  return new Stage(name, (base, vcs) -> {
    Version sanitized = sanitizeStage(base, name, true);
    String previousStage = sanitized.getPreReleaseVersion().split("\\.")[0];
    if (name.equals(previousStage)) {
      return sanitized.incrementPreReleaseVersion();
    } else {
      return base.setPreReleaseVersion(name).incrementPreReleaseVersion();
    }
  });
}

相关文章