(
projectPath: string,
layout: RemoteProjectLayout,
initLogger: InitLogger,
abortSignal?: AbortSignal,
options: { forceNoThin?: boolean } = {}
)
| 2318 | } |
| 2319 | |
| 2320 | protected async syncProjectToRemoteOnce( |
| 2321 | projectPath: string, |
| 2322 | layout: RemoteProjectLayout, |
| 2323 | initLogger: InitLogger, |
| 2324 | abortSignal?: AbortSignal, |
| 2325 | options: { forceNoThin?: boolean } = {} |
| 2326 | ): Promise<void> { |
| 2327 | if (abortSignal?.aborted) { |
| 2328 | throw new Error(OPERATION_ABORTED_ERROR); |
| 2329 | } |
| 2330 | |
| 2331 | const currentSnapshotPath = layout.currentSnapshotPath; |
| 2332 | const useNativeGitPush = this.transport instanceof OpenSSHTransport; |
| 2333 | const snapshotDigest = await this.computeSnapshotDigest(projectPath); |
| 2334 | const { baseRepoPathArg, freshlyCreated } = await this.ensureBaseRepo( |
| 2335 | projectPath, |
| 2336 | initLogger, |
| 2337 | abortSignal |
| 2338 | ); |
| 2339 | |
| 2340 | // Treat the shared bare repo as a managed cache: verify its health before |
| 2341 | // we ask Git to negotiate another sync against a fragmented object store. |
| 2342 | // |
| 2343 | // STARTUP-PERF: When ensureBaseRepo just created the bare repo, we know |
| 2344 | // it has zero packs — there is nothing to be fragmented yet. Skip the |
| 2345 | // remote `count-objects -v` probe (~80-100ms SSH round-trip) on the cold |
| 2346 | // path; the next sync against a populated repo will run it normally. |
| 2347 | if (!freshlyCreated) { |
| 2348 | await this.ensureHealthyBaseRepoForSync(baseRepoPathArg, initLogger, abortSignal); |
| 2349 | } |
| 2350 | |
| 2351 | const snapshotStatusCheck = await execBuffered( |
| 2352 | this, |
| 2353 | [ |
| 2354 | 'current_snapshot=""', |
| 2355 | `if test -f ${this.quoteForRemote(currentSnapshotPath)}; then`, |
| 2356 | ` current_snapshot=$(tr -d '\n' < ${this.quoteForRemote(currentSnapshotPath)})`, |
| 2357 | "fi", |
| 2358 | `if test "$current_snapshot" = ${shescape.quote(snapshotDigest)}; then`, |
| 2359 | ` staged_ref=$(git -C ${baseRepoPathArg} for-each-ref --count=1 --format='%(refname)' ${shescape.quote(BUNDLE_REF_PREFIX)})`, |
| 2360 | ' if test -n "$staged_ref"; then', |
| 2361 | " echo reusable", |
| 2362 | " else", |
| 2363 | " echo stale-current", |
| 2364 | " fi", |
| 2365 | "else", |
| 2366 | " echo missing", |
| 2367 | "fi", |
| 2368 | ].join("\n"), |
| 2369 | { cwd: "/tmp", timeout: 10, abortSignal } |
| 2370 | ); |
| 2371 | const snapshotStatus = snapshotStatusCheck.stdout.trim(); |
| 2372 | if (snapshotStatus === "reusable") { |
| 2373 | const localRefManifest = await this.resolveLocalSyncRefManifest(projectPath); |
| 2374 | const remoteRefManifest = |
| 2375 | localRefManifest == null |
| 2376 | ? null |
| 2377 | : await this.resolveRemoteSyncRefManifest(baseRepoPathArg, abortSignal); |
no test coverage detected