From 97bc25ed50dc6912b8d343bbfd93d5d62c35d0f6 Mon Sep 17 00:00:00 2001 From: Alexander Probst Date: Wed, 13 May 2026 11:09:20 +0200 Subject: [PATCH 1/3] SP-159: do not move package to space if branch package --- .../configuration-management/studio.service.ts | 3 ++- src/core/utils/branches.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/core/utils/branches.ts diff --git a/src/commands/configuration-management/studio.service.ts b/src/commands/configuration-management/studio.service.ts index 0f63162e..b729460b 100644 --- a/src/commands/configuration-management/studio.service.ts +++ b/src/commands/configuration-management/studio.service.ts @@ -23,6 +23,7 @@ import { SpaceApi } from "../studio/api/space-api"; import { StudioVariablesApi } from "../studio/api/studio-variables-api"; import { SpaceService } from "../studio/service/space.service"; import { StudioVariableService } from "../studio/service/studio-variable.service"; +import { BranchUtils } from "../../core/utils/branches"; export class StudioService { @@ -103,7 +104,7 @@ export class StudioService { } for (const manifest of studioManifests) { const existingPackage = existingStudioPackages.find(existingPackage => existingPackage.key === manifest.packageKey); - if (existingPackage) { + if (existingPackage && !BranchUtils.isBranchPackageKey(existingPackage.key)) { await this.studioPackageApi.movePackageToSpace(existingPackage.id, manifest.space.id); } await this.assignRuntimeVariables(manifest); diff --git a/src/core/utils/branches.ts b/src/core/utils/branches.ts new file mode 100644 index 00000000..ffd389c5 --- /dev/null +++ b/src/core/utils/branches.ts @@ -0,0 +1,16 @@ +export class BranchUtils { + private static readonly BRANCH_SEPARATOR = "@"; + + /** + * Checks if a package key represents a branch. + * @param packageKey The string to check + * @throws Error if the package key is null, undefined, or empty/whitespace + */ + public static isBranchPackageKey(packageKey: string): boolean { + if (!packageKey || packageKey.trim().length === 0) { + throw new Error("Package key cannot be empty"); + } + + return packageKey.includes(BranchUtils.BRANCH_SEPARATOR); + } +} \ No newline at end of file From 6d46712909a89739fe907382e69b421bdec12547 Mon Sep 17 00:00:00 2001 From: Alexander Probst Date: Fri, 15 May 2026 09:40:41 +0200 Subject: [PATCH 2/3] SP-159: added tests for BranchUtils --- tests/core/utils/branches.spec.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/core/utils/branches.spec.ts diff --git a/tests/core/utils/branches.spec.ts b/tests/core/utils/branches.spec.ts new file mode 100644 index 00000000..bfff629a --- /dev/null +++ b/tests/core/utils/branches.spec.ts @@ -0,0 +1,25 @@ +import { BranchUtils } from "../../../src/core/utils/branches"; + +describe("BranchUtils", () => { + describe("isBranchPackageKey", () => { + it("should return true when package key contains branch separator", () => { + expect(BranchUtils.isBranchPackageKey("package@feature-branch")).toBe(true); + }); + + it("should return false when package key does not contain branch separator", () => { + expect(BranchUtils.isBranchPackageKey("package")).toBe(false); + }); + + it("should throw an error if the input is empty", () => { + expect(() => BranchUtils.isBranchPackageKey("")).toThrow("Package key cannot be empty"); + }); + + it("should throw an error if the input is only whitespace", () => { + expect(() => BranchUtils.isBranchPackageKey(" ")).toThrow("Package key cannot be empty"); + }); + + it("should throw an error if the input is null", () => { + expect(() => BranchUtils.isBranchPackageKey(null)).toThrow("Package key cannot be empty"); + }); + }); +}); From fdd9ab6c7e4d757465f50b20cdb6f3f0d7258c5f Mon Sep 17 00:00:00 2001 From: Alexander Probst Date: Fri, 15 May 2026 11:03:12 +0200 Subject: [PATCH 3/3] SP-159: cleanup --- src/core/utils/branches.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/utils/branches.ts b/src/core/utils/branches.ts index ffd389c5..d205291b 100644 --- a/src/core/utils/branches.ts +++ b/src/core/utils/branches.ts @@ -1,11 +1,6 @@ export class BranchUtils { private static readonly BRANCH_SEPARATOR = "@"; - /** - * Checks if a package key represents a branch. - * @param packageKey The string to check - * @throws Error if the package key is null, undefined, or empty/whitespace - */ public static isBranchPackageKey(packageKey: string): boolean { if (!packageKey || packageKey.trim().length === 0) { throw new Error("Package key cannot be empty");