mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-24 00:00:46 +00:00
dcee9fe7b1
* fix(cli): prevent duplicate 'Using non-dotted paths' log message Add a flag to track whether the message has already been logged, so it only prints once even if setNonDottedPaths is called multiple times. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(cli): add --branch option to sync pull/push commands Add a --branch argument that allows overriding the current git branch for sync operations. This enables: - Using branch-specific settings even when not in a git repository - Overriding the detected git branch when needed The branch override is applied to: - getEffectiveSettings() for branch-specific config overrides - getSpecificItemsForCurrentBranch() for branch-specific items Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): correct log message for workspace fork branches Use rawGitBranch instead of currentBranch in the log message when showing the origin of a workspace fork branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(cli): extend --branch support to specificItems functionality Update getBranchSpecificPath and isCurrentBranchFile to accept optional branchOverride parameter. This ensures that branch-specific file handling (for variables, resources, triggers) works correctly with --branch flag. Updated functions: - getBranchSpecificPath(): now accepts branchOverride - isCurrentBranchFile(): now accepts branchOverride - elementsToMap(): now accepts branchOverride - compareDynFSElement(): now accepts branchOverride - prettyChanges(): now accepts branchOverride All call sites updated to pass opts.branch through the call chain. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(cli): resolve TypeScript type errors - Fix Timeout type in dev.ts using ReturnType<typeof setTimeout> - Add proper type casts for unknown error types - Cast FlowModule to any to resolve generated type mismatch - Cast Uint8Array to BlobPart for Blob constructor compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test(cli): add unit tests for branch detection and --branch override - Add specific_items.test.ts with 35 tests covering: - toBranchSpecificPath and fromBranchSpecificPath conversions - isSpecificItem pattern matching - isBranchSpecificFile detection - Round-trip path conversions - branchOverride parameter functionality - Add conf_branch_override.test.ts with 6 tests covering: - getEffectiveSettings with branchOverride parameter - Branch-specific overrides application - promotionOverrides precedence - Fallback to top-level settings - Fix containerized_backend.ts to use dynamic paths instead of hardcoded user home directories Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore(cli): add conf.ts barrel file for test imports Re-exports from src/core/conf.ts to support existing test imports. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * all * fix(cli): pass --branch override to workspace resolution Previously, the --branch flag was only used for config resolution but not for workspace resolution. This caused confusing log messages that showed the git branch (e.g., master) before showing the override branch. Changes: - Add branchOverride parameter to tryResolveBranchWorkspace() - Add branchOverride parameter to resolveWorkspace() - Pass opts.branch from sync pull/push to resolveWorkspace() - Log "Using branch override" early in workspace resolution - Remove duplicate log from getEffectiveSettings() Now when using --branch foobar, the logs show: Using branch override: foobar Applied settings for Git branch: foobar ... Instead of the confusing previous output that mentioned both master and foobar. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor(cli): remove redundant branch detection in elementsToMap isCurrentBranchFile() already validates that a branch exists (via branchOverride or git detection) before returning true. No need to pre-compute currentBranch before calling it. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
145 lines
4.6 KiB
TypeScript
145 lines
4.6 KiB
TypeScript
import { assertEquals, assertExists } from "https://deno.land/std@0.224.0/assert/mod.ts";
|
|
import { getEffectiveSettings, type SyncOptions } from "../src/core/conf.ts";
|
|
|
|
// =============================================================================
|
|
// CONF.TS BRANCH OVERRIDE TESTS
|
|
// Tests for getEffectiveSettings with branchOverride parameter
|
|
// =============================================================================
|
|
|
|
Deno.test("getEffectiveSettings: applies branch overrides when branchOverride is provided", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
gitBranches: {
|
|
staging: {
|
|
overrides: {
|
|
includes: ["staging/**"],
|
|
skipVariables: true,
|
|
},
|
|
},
|
|
production: {
|
|
overrides: {
|
|
includes: ["prod/**"],
|
|
skipSecrets: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
// Test with staging branch override
|
|
const stagingSettings = await getEffectiveSettings(config, undefined, true, true, "staging");
|
|
assertEquals(stagingSettings.includes, ["staging/**"]);
|
|
assertEquals(stagingSettings.skipVariables, true);
|
|
assertEquals(stagingSettings.skipSecrets, undefined);
|
|
|
|
// Test with production branch override
|
|
const prodSettings = await getEffectiveSettings(config, undefined, true, true, "production");
|
|
assertEquals(prodSettings.includes, ["prod/**"]);
|
|
assertEquals(prodSettings.skipSecrets, true);
|
|
assertEquals(prodSettings.skipVariables, undefined);
|
|
});
|
|
|
|
Deno.test("getEffectiveSettings: uses top-level settings when branchOverride has no overrides", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
skipVariables: true,
|
|
gitBranches: {
|
|
staging: {
|
|
// No overrides defined
|
|
},
|
|
},
|
|
};
|
|
|
|
const settings = await getEffectiveSettings(config, undefined, true, true, "staging");
|
|
assertEquals(settings.includes, ["f/**"]);
|
|
assertEquals(settings.skipVariables, true);
|
|
assertEquals(settings.defaultTs, "bun");
|
|
});
|
|
|
|
Deno.test("getEffectiveSettings: uses top-level settings for unknown branch", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
gitBranches: {
|
|
staging: {
|
|
overrides: {
|
|
includes: ["staging/**"],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const settings = await getEffectiveSettings(config, undefined, true, true, "nonexistent");
|
|
assertEquals(settings.includes, ["f/**"]);
|
|
assertEquals(settings.defaultTs, "bun");
|
|
});
|
|
|
|
Deno.test("getEffectiveSettings: promotionOverrides take precedence when promotion specified", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
gitBranches: {
|
|
production: {
|
|
overrides: {
|
|
includes: ["prod/**"],
|
|
},
|
|
promotionOverrides: {
|
|
includes: ["promoted/**"],
|
|
skipVariables: true,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
// Test without promotion flag - should use regular overrides
|
|
const normalSettings = await getEffectiveSettings(config, undefined, true, true, "production");
|
|
assertEquals(normalSettings.includes, ["prod/**"]);
|
|
assertEquals(normalSettings.skipVariables, undefined);
|
|
|
|
// Test with promotion flag - should use promotionOverrides
|
|
const promoSettings = await getEffectiveSettings(config, "production", true, true);
|
|
assertEquals(promoSettings.includes, ["promoted/**"]);
|
|
assertEquals(promoSettings.skipVariables, true);
|
|
});
|
|
|
|
Deno.test("getEffectiveSettings: branchOverride works without gitBranches config", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
};
|
|
|
|
// Should not throw even with branchOverride but no gitBranches
|
|
const settings = await getEffectiveSettings(config, undefined, true, true, "staging");
|
|
assertEquals(settings.includes, ["f/**"]);
|
|
assertEquals(settings.defaultTs, "bun");
|
|
});
|
|
|
|
Deno.test("getEffectiveSettings: preserves all top-level settings in merged result", async () => {
|
|
const config: SyncOptions = {
|
|
defaultTs: "bun",
|
|
includes: ["f/**"],
|
|
excludes: ["*.test.ts"],
|
|
skipVariables: false,
|
|
skipResources: false,
|
|
skipFlows: false,
|
|
parallel: 4,
|
|
gitBranches: {
|
|
staging: {
|
|
overrides: {
|
|
skipVariables: true, // Override just this one
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const settings = await getEffectiveSettings(config, undefined, true, true, "staging");
|
|
assertEquals(settings.defaultTs, "bun");
|
|
assertEquals(settings.includes, ["f/**"]);
|
|
assertEquals(settings.excludes, ["*.test.ts"]);
|
|
assertEquals(settings.skipVariables, true); // Overridden
|
|
assertEquals(settings.skipResources, false);
|
|
assertEquals(settings.skipFlows, false);
|
|
assertEquals(settings.parallel, 4);
|
|
});
|