Skip to content

Commit 9cc457b

Browse files
authored
fix: call git remote set-branches when running with a different branch from previous run (#386)
1 parent 3bedf86 commit 9cc457b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

utils.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ export async function setupRepo(options: RepoOptions) {
130130
} catch {
131131
// when not a git repo
132132
}
133+
if (repo === currentClonedRepo) {
134+
const isShallow =
135+
(await $`git rev-parse --is-shallow-repository`).trim() === 'true'
136+
if (isShallow === shallow) {
137+
needClone = false
138+
}
139+
}
133140
cd(_cwd)
134141

135-
if (repo === currentClonedRepo) {
136-
needClone = false
137-
} else {
142+
if (needClone) {
138143
fs.rmSync(dir, { recursive: true, force: true })
139144
}
140145
}
@@ -146,6 +151,9 @@ export async function setupRepo(options: RepoOptions) {
146151
}
147152
cd(dir)
148153
await $`git clean -fdxq`
154+
if (!needClone && shallow && !commit) {
155+
await $`git remote set-branches origin ${branch}`
156+
}
149157
await $`git fetch ${shallow ? '--depth=1 --no-tags' : '--tags'} origin ${
150158
tag ? `tag ${tag}` : `${commit || branch}`
151159
}`

0 commit comments

Comments
 (0)