File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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 } `
You can’t perform that action at this time.
0 commit comments