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
6 changes: 4 additions & 2 deletions src/domain/repo/swamp_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class SwampVersion {
readonly major: number,
readonly minor: number,
readonly patch: number,
private readonly rawVersion: string,
) {}

/**
Expand Down Expand Up @@ -58,7 +59,8 @@ export class SwampVersion {
const minor = parseInt(match[2], 10);
const patch = parseInt(match[3], 10);

return new SwampVersion(major, minor, patch);
const rawVersion = `${match[1]}.${match[2]}.${match[3]}`;
return new SwampVersion(major, minor, patch, rawVersion);
}

/**
Expand Down Expand Up @@ -104,6 +106,6 @@ export class SwampVersion {
* Returns the version as a string (e.g., "1.0.0").
*/
toString(): string {
return `${this.major}.${this.minor}.${this.patch}`;
return this.rawVersion;
}
}
11 changes: 11 additions & 0 deletions src/domain/repo/swamp_version_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ Deno.test("SwampVersion.create accepts calver format with sha suffix", () => {
assertEquals(v.patch, 0);
});

Deno.test("SwampVersion.create preserves leading zeros in calver time component", () => {
const v = SwampVersion.create("20260224.003901.0");
assertEquals(v.toString(), "20260224.003901.0");
assertEquals(v.minor, 3901);
});

Deno.test("SwampVersion.create preserves leading zeros with sha suffix", () => {
const v = SwampVersion.create("20260224.003901.0-sha.abc123");
assertEquals(v.toString(), "20260224.003901.0");
});

Deno.test("SwampVersion.create accepts dev version", () => {
const v = SwampVersion.create("0.0.0-dev");
assertEquals(v.major, 0);
Expand Down