mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-29 00:07:30 +00:00
fix: write gitsync-settings pull overrides to the resolved workspace entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a7579fb2ad
commit
58ebf930f7
@@ -22,7 +22,8 @@ import {
|
||||
applyBackendSettingsToBranch,
|
||||
normalizeRepoPath,
|
||||
outputResult,
|
||||
getEffectiveSettingsForWorkspace
|
||||
getEffectiveSettingsForWorkspace,
|
||||
resolveGitSyncWsName
|
||||
} from "./utils.ts";
|
||||
|
||||
export async function pullGitSyncSettings(
|
||||
@@ -441,12 +442,21 @@ export async function pullGitSyncSettings(
|
||||
}
|
||||
}
|
||||
|
||||
// For override mode, write to branch overrides
|
||||
if (writeMode === "override" && isGitRepository()) {
|
||||
const currentBranch = getCurrentGitBranch();
|
||||
if (currentBranch) {
|
||||
log.info(`Detected Git repository, writing settings to branch: ${currentBranch}`);
|
||||
updatedConfig = applyBackendSettingsToBranch(localConfig, currentBranch, backendSyncOptions);
|
||||
// Override mode writes to the entry the diff was computed against, so a
|
||||
// second pull finds no conflict
|
||||
let overrideTarget: string | undefined;
|
||||
if (writeMode === "override") {
|
||||
overrideTarget = resolveGitSyncWsName(localConfig, opts, workspace);
|
||||
if (!overrideTarget && isGitRepository()) {
|
||||
const currentBranch = getCurrentGitBranch();
|
||||
if (currentBranch) {
|
||||
overrideTarget =
|
||||
findWorkspaceByGitBranch(localConfig.workspaces, currentBranch)?.[0] ?? currentBranch;
|
||||
}
|
||||
}
|
||||
if (overrideTarget) {
|
||||
log.info(`Writing settings to workspace entry: ${overrideTarget}`);
|
||||
updatedConfig = applyBackendSettingsToBranch(localConfig, overrideTarget, backendSyncOptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,10 +478,9 @@ export async function pullGitSyncSettings(
|
||||
),
|
||||
);
|
||||
if (writeMode === "override") {
|
||||
const currentBranch = getCurrentGitBranch();
|
||||
if (currentBranch) {
|
||||
if (overrideTarget) {
|
||||
log.info(
|
||||
colors.gray(`Settings written to branch '${currentBranch}' overrides`),
|
||||
colors.gray(`Settings written to workspace '${overrideTarget}' overrides`),
|
||||
);
|
||||
}
|
||||
} else if (writeMode === "replace") {
|
||||
|
||||
@@ -29,20 +29,29 @@ export function outputResult(opts: { jsonOutput?: boolean }, result: {
|
||||
}
|
||||
|
||||
/**
|
||||
* The wmill.yaml settings that apply to the workspace being synced. Resolved by
|
||||
* workspace first, as `sync pull/push` do: several entries can share one
|
||||
* `gitBranch`, so matching on the checked-out branch alone picks whichever of
|
||||
* them comes first in the file.
|
||||
* The wmill.yaml entry of the workspace being synced, resolved by workspace as
|
||||
* `sync pull/push` do: several entries can share one `gitBranch`, so matching on
|
||||
* the checked-out branch alone picks whichever of them comes first in the file.
|
||||
* Undefined when no entry names this workspace.
|
||||
*/
|
||||
export function resolveGitSyncWsName(
|
||||
config: SyncOptions,
|
||||
opts: { workspace?: string },
|
||||
workspace: { remote: string; workspaceId: string },
|
||||
): string | undefined {
|
||||
return (
|
||||
resolveWsNameForConfigFromFlags({ workspaces: config.workspaces, workspace: opts.workspace }) ??
|
||||
inferWsNameFromProfile(config, workspace) ??
|
||||
inferWsNameFromForkBranch(config, workspace.workspaceId)
|
||||
);
|
||||
}
|
||||
|
||||
export async function getEffectiveSettingsForWorkspace(
|
||||
config: SyncOptions,
|
||||
opts: { workspace?: string; promotion?: string; jsonOutput?: boolean },
|
||||
workspace: { remote: string; workspaceId: string },
|
||||
): Promise<SyncOptions> {
|
||||
const wsName =
|
||||
resolveWsNameForConfigFromFlags({ workspaces: config.workspaces, workspace: opts.workspace }) ??
|
||||
inferWsNameFromProfile(config, workspace) ??
|
||||
inferWsNameFromForkBranch(config, workspace.workspaceId);
|
||||
const wsName = resolveGitSyncWsName(config, opts, workspace);
|
||||
return await getEffectiveSettings(config, opts.promotion, true, opts.jsonOutput, wsName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user