mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 14:12:51 +00:00
25 lines
798 B
TypeScript
25 lines
798 B
TypeScript
import type { Logger } from "pino";
|
|
import type { ServiceProxySubsystem } from "./service-proxy.js";
|
|
|
|
interface BranchChangeRouteHandlerOptions {
|
|
serviceProxy: ServiceProxySubsystem;
|
|
onRoutesChanged: (workspaceId: string) => void;
|
|
logger?: Logger;
|
|
}
|
|
|
|
export function createBranchChangeRouteHandler(
|
|
options: BranchChangeRouteHandlerOptions,
|
|
): (workspaceId: string, oldBranch: string | null, newBranch: string | null) => void {
|
|
return (workspaceId, _oldBranch, newBranch) => {
|
|
const changed = options.serviceProxy.replaceWorkspaceBranchRoutes({ workspaceId, newBranch });
|
|
if (!changed) {
|
|
return;
|
|
}
|
|
options.logger?.info(
|
|
{ workspaceId, newBranch },
|
|
"Updated service proxy routes for branch rename",
|
|
);
|
|
options.onRoutesChanged(workspaceId);
|
|
};
|
|
}
|