(opts: CloneWithDeps)
| 103 | } |
| 104 | |
| 105 | export async function cloneWith(opts: CloneWithDeps): Promise<void> { |
| 106 | const dir = opts.dir ?? "/"; |
| 107 | const ref = opts.ref; |
| 108 | const depthRaw = opts.depth ?? 1; |
| 109 | // depth=0 and depth=Infinity both mean "no shallow limit" on this |
| 110 | // surface. isomorphic-git interprets `undefined` that way. |
| 111 | const depth = depthRaw > 0 && Number.isFinite(depthRaw) ? depthRaw : undefined; |
| 112 | |
| 113 | await opts.git.clone({ |
| 114 | fs: opts.fs, |
| 115 | http: opts.http, |
| 116 | dir, |
| 117 | url: opts.url, |
| 118 | ref, |
| 119 | corsProxy: opts.corsProxy, |
| 120 | headers: opts.headers, |
| 121 | depth, |
| 122 | singleBranch: opts.singleBranch ?? true, |
| 123 | noTags: opts.noTags ?? true, |
| 124 | noCheckout: true, |
| 125 | cache: opts.cache, |
| 126 | onProgress: opts.onProgress, |
| 127 | onMessage: opts.onMessage, |
| 128 | }); |
| 129 | |
| 130 | // The working tree is empty after a noCheckout clone, so `force` |
| 131 | // is safe — nothing real can conflict — and matches caller intent |
| 132 | // ("populate this workspace from the remote"). |
| 133 | // |
| 134 | // `git.clone` already wrote HEAD as a symbolic ref to the fetched |
| 135 | // branch. Checking out `ref: "HEAD"` here would re-resolve it to |
| 136 | // an oid and detach HEAD, because isomorphic-git only writes a |
| 137 | // symbolic HEAD when the checkout ref expands to `refs/heads/*`. |
| 138 | // `noUpdateHead` materializes the working tree without touching |
| 139 | // HEAD, preserving the symbolic ref the clone left in place. |
| 140 | await opts.git.checkout({ |
| 141 | fs: opts.fs, |
| 142 | dir, |
| 143 | ref: ref ?? "HEAD", |
| 144 | filepaths: opts.paths, |
| 145 | force: true, |
| 146 | noUpdateHead: true, |
| 147 | cache: opts.cache, |
| 148 | }); |
| 149 | } |
no test coverage detected