Skip to content

Commit a2a0b9b

Browse files
committed
feat: sanatize error message
1 parent 05dd8b5 commit a2a0b9b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/git.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,10 @@ export async function getWorktreeRepo(
515515
): Promise<Git> {
516516
debug(`Creating worktree repo at: ${worktreePath}`)
517517

518-
// Create worktree from main repo
519518
await mainRepo.createWorktree(worktreePath, branch)
520519

521-
// Create new Git instance for the worktree
522520
const worktreeRepo = new Git(worktreePath, mainRepo.url, mainRepo.user, mainRepo.email, mainRepo.urlAuth, branch)
523521

524-
// Set up git config for the worktree
525522
await worktreeRepo.addConfig()
526523
await worktreeRepo.initSops()
527524

src/otomi-stack.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CoreV1Api, User as k8sUser, KubeConfig, V1ObjectReference } from '@kubernetes/client-node'
1+
import { CoreV1Api, KubeConfig, User as k8sUser, V1ObjectReference } from '@kubernetes/client-node'
22
import Debug from 'debug'
33

44
import { getRegions, ObjectStorageKeyRegions } from '@linode/api-v4'
@@ -335,17 +335,18 @@ export default class OtomiStack {
335335
await this.init()
336336
debug(`Creating worktree for session ${this.sessionId}`)
337337

338-
// Verify main repo has the branch we want to use
339338
try {
340339
await mainRepo.git.revparse(`--verify refs/heads/${env.GIT_BRANCH}`)
341340
} catch (error) {
342-
throw new Error(`Main repository does not have branch '${env.GIT_BRANCH}'. Cannot create worktree.`)
341+
const errorMessage = getSanitizedErrorMessage(error)
342+
throw new Error(
343+
`Main repository does not have branch '${env.GIT_BRANCH}'. Cannot create worktree. ${errorMessage}`,
344+
)
343345
}
344346

345347
const worktreePath = this.getRepoPath()
346348
this.git = await getWorktreeRepo(mainRepo, worktreePath, env.GIT_BRANCH)
347349

348-
// No need to pull as worktree is already in sync with main repo
349350
debug(`Worktree created for ${this.editor} in ${this.sessionId}`)
350351
}
351352

0 commit comments

Comments
 (0)