Skip to content

Commit df5e317

Browse files
committed
fix: address review feedback
- rename fetchBranch to fetchAndTrackBranch to reflect that it also creates the local branch and sets upstream tracking - relabel the attach-side error to "Failed to fetch/track branch" so a failure during the tracking step isn't mis-reported as a fetch failure - shorten redundant "note: PR lookup failed — skipping PR lookup" to "note: PR lookup failed — skipping"
1 parent 6f33ada commit df5e317

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

packages/cli/src/commands/worktree/attach.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getPrForBranch } from '../../lib/gh.js'
44
import {
55
addWorktreeExisting,
66
branchExists,
7-
fetchBranch,
7+
fetchAndTrackBranch,
88
listWorktrees,
99
remoteBranchExists,
1010
} from '../../lib/git.js'
@@ -74,13 +74,13 @@ export async function attachCommand(
7474
process.exit(1)
7575
}
7676
try {
77-
await fetchBranch('origin', branch)
77+
await fetchAndTrackBranch('origin', branch)
7878
} catch (err) {
7979
const stderr =
8080
err && typeof err === 'object' && 'stderr' in err
8181
? String(err.stderr).trim()
8282
: String(err)
83-
console.error(`Failed to fetch branch: ${stderr}`)
83+
console.error(`Failed to fetch/track branch: ${stderr}`)
8484
process.exit(1)
8585
}
8686
}
@@ -115,7 +115,7 @@ export async function attachCommand(
115115
prNumber = lookup.pr
116116
} else if (!opts.printPath) {
117117
if (lookup.kind === 'unavailable') {
118-
console.log('note: PR lookup failed — skipping PR lookup')
118+
console.log('note: PR lookup failed — skipping')
119119
} else {
120120
console.log(`note: no open PR found for "${branch}"`)
121121
}

packages/cli/src/lib/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export async function remoteBranchExists(
124124
return out.length > 0
125125
}
126126

127-
export async function fetchBranch(remote: string, branch: string) {
127+
export async function fetchAndTrackBranch(remote: string, branch: string) {
128128
const root = await getRepoRoot()
129129
// Plain `git fetch <remote> <branch>` uses the configured refspec and updates
130130
// refs/remotes/<remote>/<branch>; an explicit `<branch>:<branch>` refspec

0 commit comments

Comments
 (0)