Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions __snapshots__/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.google.cloud.example;
public final class Version {
// {x-release-please-start-version}
public static String VERSION = "2.3.4";
public static String VERSION = "v2.3.4";
// {x-release-please-end}

// {x-release-please-start-date}
Expand All @@ -28,10 +29,12 @@ public final class Version {
// {x-release-please-start-version-date}
public static String NEW_DATE = "01-12-2023";
public static String NEW_VERSION = "2.3.4";
public static String NEW_VERSION_V = "v2.3.4";
// {x-release-please-end}

// {x-release-please-start-major}
public static String MAJOR = "2";
public static String MAJOR_V = "v2";
// {x-release-please-end}

// {x-release-please-start-minor}
Expand All @@ -44,6 +47,7 @@ public final class Version {

public static String INLINE_VERSION = "2.3.4"; // {x-release-please-version}
public static String INLINE_MAJOR = "2"; // {x-release-please-major}
public static String INLINE_MAJOR_V = "v2"; // {x-release-please-major}
public static String INLINE_MINOR = "3"; // {x-release-please-minor}
public static String INLINE_PATCH = "4"; // {x-release-please-patch}

Expand Down
3 changes: 2 additions & 1 deletion src/updaters/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {logger as defaultLogger, Logger} from '../util/logger';

const VERSION_REGEX =
/(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<preRelease>[\w.]+))?(\+(?<build>[-\w.]+))?/;
const MAJOR_VERSION_REGEX = /\d+\b/;
const SINGLE_VERSION_REGEX = /\b\d+\b/;
const INLINE_UPDATE_REGEX =
/x-release-please-(?<scope>major|minor|patch|version-date|version|date)/;
Expand Down Expand Up @@ -134,7 +135,7 @@ export class Generic extends DefaultUpdater {
newLines.push(line.replace(VERSION_REGEX, version.toString()));
return;
case 'major':
newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.major}`));
newLines.push(line.replace(MAJOR_VERSION_REGEX, `${version.major}`));
return;
case 'minor':
newLines.push(line.replace(SINGLE_VERSION_REGEX, `${version.minor}`));
Expand Down
4 changes: 4 additions & 0 deletions test/updaters/fixtures/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
public final class Version {
// {x-release-please-start-version}
public static String VERSION = "1.2.3-SNAPSHOT";
public static String VERSION = "v1.2.3-SNAPSHOT";
// {x-release-please-end}

// {x-release-please-start-date}
Expand All @@ -27,10 +28,12 @@ public final class Version {
// {x-release-please-start-version-date}
public static String NEW_DATE = "01-01-0100";
public static String NEW_VERSION = "3.2.0-SNAPSHOT";
public static String NEW_VERSION_V = "v3.2.0-SNAPSHOT";
// {x-release-please-end}

// {x-release-please-start-major}
public static String MAJOR = "1";
public static String MAJOR_V = "v1";
// {x-release-please-end}

// {x-release-please-start-minor}
Expand All @@ -43,6 +46,7 @@ public final class Version {

public static String INLINE_VERSION = "1.2.3-SNAPSHOT"; // {x-release-please-version}
public static String INLINE_MAJOR = "1"; // {x-release-please-major}
public static String INLINE_MAJOR_V = "v1"; // {x-release-please-major}
public static String INLINE_MINOR = "2"; // {x-release-please-minor}
public static String INLINE_PATCH = "3"; // {x-release-please-patch}

Expand Down
Loading