From 4bb930bb365b5e056c9c42827295d9ef2b6ee02d Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 9 Jul 2026 18:52:01 +0200 Subject: [PATCH] fix: target decision center data repo --- config/unidesk-host-k8s.yaml | 4 ++-- .../microservices/decision-center/src/index.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config/unidesk-host-k8s.yaml b/config/unidesk-host-k8s.yaml index 1acc97d9..1ae8ea51 100644 --- a/config/unidesk-host-k8s.yaml +++ b/config/unidesk-host-k8s.yaml @@ -84,8 +84,8 @@ services: storage: primary: github-repo github: - repo: pikasTech/unidesk-decision-center-data - sshUrl: git@github.com:pikasTech/unidesk-decision-center-data.git + repo: pikasTech/decision-center-data + sshUrl: git@github.com:pikasTech/decision-center-data.git branch: main basePath: data worktreePath: /var/lib/unidesk/decision-center/repo diff --git a/src/components/microservices/decision-center/src/index.ts b/src/components/microservices/decision-center/src/index.ts index 0c9c4314..b173add5 100644 --- a/src/components/microservices/decision-center/src/index.ts +++ b/src/components/microservices/decision-center/src/index.ts @@ -985,12 +985,21 @@ function ensureGitWorktree(): void { mkdirSync(dirname(config.storage.worktreePath), { recursive: true }); if (!existsSync(join(config.storage.worktreePath, ".git"))) { if (existsSync(config.storage.worktreePath)) rmSync(config.storage.worktreePath, { recursive: true, force: true }); - runGit(["clone", "--branch", config.storage.branch, config.storage.repoSshUrl, config.storage.worktreePath], { cwd: dirname(config.storage.worktreePath) }); + runGit(["clone", config.storage.repoSshUrl, config.storage.worktreePath], { cwd: dirname(config.storage.worktreePath) }); } runGit(["remote", "set-url", "origin", config.storage.repoSshUrl]); - runGit(["fetch", "origin", config.storage.branch]); - runGit(["checkout", config.storage.branch]); - runGit(["pull", "--ff-only", "origin", config.storage.branch]); + const fetchedBranch = runGit(["fetch", "origin", config.storage.branch], { allowFailure: true }); + if (fetchedBranch.ok) { + runGit(["checkout", "-B", config.storage.branch, `origin/${config.storage.branch}`]); + runGit(["pull", "--ff-only", "origin", config.storage.branch]); + return; + } + const hasLocalCommit = runGit(["rev-parse", "--verify", "HEAD"], { allowFailure: true }); + if (hasLocalCommit.ok) { + runGit(["checkout", "-B", config.storage.branch]); + } else { + runGit(["symbolic-ref", "HEAD", `refs/heads/${config.storage.branch}`]); + } } function gitHeadSummary(): JsonRecord {