@catamorphic/git 0.1.0-alpha.43 → 0.1.0-alpha.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/checkout-remote-backend.d.ts.map +1 -1
  2. package/dist/fs-backend.d.ts +8 -0
  3. package/dist/fs-backend.d.ts.map +1 -1
  4. package/dist/fs-remote-backend.d.ts +43 -9
  5. package/dist/fs-remote-backend.d.ts.map +1 -1
  6. package/dist/git-objects.d.ts +77 -0
  7. package/dist/git-objects.d.ts.map +1 -0
  8. package/dist/git-sync.d.ts +16 -17
  9. package/dist/git-sync.d.ts.map +1 -1
  10. package/dist/index.d.ts +4 -4
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +3824 -3099
  13. package/dist/index.js.map +23 -22
  14. package/dist/native-git.d.ts +114 -2
  15. package/dist/native-git.d.ts.map +1 -1
  16. package/dist/native-project-repo.d.ts +40 -5
  17. package/dist/native-project-repo.d.ts.map +1 -1
  18. package/dist/network-sync.d.ts.map +1 -1
  19. package/dist/network.d.ts +14 -9
  20. package/dist/network.d.ts.map +1 -1
  21. package/dist/object-origin-cache.d.ts +86 -0
  22. package/dist/object-origin-cache.d.ts.map +1 -0
  23. package/dist/object-remote-backend.d.ts +64 -10
  24. package/dist/object-remote-backend.d.ts.map +1 -1
  25. package/dist/origin-draft.d.ts.map +1 -1
  26. package/dist/origin-objects.d.ts +7 -2
  27. package/dist/origin-objects.d.ts.map +1 -1
  28. package/dist/project-manager.d.ts +22 -0
  29. package/dist/project-manager.d.ts.map +1 -1
  30. package/dist/project-paths.d.ts +20 -0
  31. package/dist/project-paths.d.ts.map +1 -0
  32. package/dist/ref-names.d.ts +35 -0
  33. package/dist/ref-names.d.ts.map +1 -1
  34. package/dist/types.d.ts +37 -4
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/workspace-checkout.d.ts.map +1 -1
  37. package/dist/workspace-mirror.d.ts +13 -1
  38. package/dist/workspace-mirror.d.ts.map +1 -1
  39. package/dist/workspace-save.d.ts +27 -2
  40. package/dist/workspace-save.d.ts.map +1 -1
  41. package/package.json +4 -4
  42. package/src/checkout-remote-backend.ts +77 -29
  43. package/src/fs-backend.ts +69 -7
  44. package/src/fs-remote-backend.ts +255 -133
  45. package/src/git-objects.ts +363 -0
  46. package/src/git-sync.ts +124 -453
  47. package/src/index.ts +9 -7
  48. package/src/native-git.ts +566 -25
  49. package/src/native-project-repo.ts +318 -99
  50. package/src/network-sync.ts +43 -35
  51. package/src/network.ts +177 -153
  52. package/src/object-origin-cache.ts +689 -0
  53. package/src/object-remote-backend.ts +277 -20
  54. package/src/origin-draft.ts +22 -15
  55. package/src/origin-objects.ts +21 -5
  56. package/src/project-manager.ts +261 -73
  57. package/src/project-paths.ts +142 -0
  58. package/src/ref-names.ts +56 -0
  59. package/src/types.ts +38 -4
  60. package/src/workspace-checkout.ts +16 -9
  61. package/src/workspace-mirror.ts +199 -58
  62. package/src/workspace-save.ts +99 -30
  63. package/dist/project-repo.d.ts +0 -81
  64. package/dist/project-repo.d.ts.map +0 -1
  65. package/src/project-repo.ts +0 -821
@@ -1,6 +1,4 @@
1
- import nodeFs from "node:fs";
2
1
  import { MANAGED_BRANCH_PREFIX } from "@catamorphic/workflow/project-layout";
3
- import git from "isomorphic-git";
4
2
  import { nativeGit } from "./native-git.js";
5
3
  import { NativeProjectRepo } from "./native-project-repo.js";
6
4
  import {
@@ -70,7 +68,9 @@ export async function syncWithNetworkRemote(opts: {
70
68
  const owned = opts.ownership === "owned";
71
69
 
72
70
  const currentBranch = await dev.currentBranch();
73
- if (dev instanceof NativeProjectRepo) {
71
+ // A person's own folder syncs the branch it is on with its upstream; a
72
+ // copy Work manages syncs its `main`.
73
+ if (dev instanceof NativeProjectRepo && !dev.managed) {
74
74
  if (currentBranch === "HEAD")
75
75
  return { status: "no-op", localSha: null, remoteSha: null };
76
76
  const localSha = await dev.resolveRef();
@@ -90,7 +90,7 @@ export async function syncWithNetworkRemote(opts: {
90
90
  const remote = (
91
91
  await nativeGit(
92
92
  dir,
93
- ["ls-remote", opts.url, `refs/heads/${target}`],
93
+ ["ls-remote", "--end-of-options", opts.url, `refs/heads/${target}`],
94
94
  auth,
95
95
  )
96
96
  ).trim();
@@ -99,7 +99,6 @@ export async function syncWithNetworkRemote(opts: {
99
99
  if (!owned) return { status: "ahead", localSha, remoteSha };
100
100
  await pushToRemote({
101
101
  repoPath: dir,
102
- native: true,
103
102
  url: opts.url,
104
103
  credentials: opts.credentials,
105
104
  ownership: opts.ownership,
@@ -111,7 +110,11 @@ export async function syncWithNetworkRemote(opts: {
111
110
  if (!remoteSha) return push();
112
111
  if (remoteSha === localSha)
113
112
  return { status: "up-to-date", localSha, remoteSha };
114
- await nativeGit(dir, ["fetch", opts.url, `refs/heads/${target}`], auth);
113
+ await nativeGit(
114
+ dir,
115
+ ["fetch", "--end-of-options", opts.url, `refs/heads/${target}`],
116
+ auth,
117
+ );
115
118
  if (
116
119
  await nativeGit(dir, [
117
120
  "merge-base",
@@ -175,9 +178,10 @@ export async function syncWithNetworkRemote(opts: {
175
178
  }
176
179
 
177
180
  const isDescendent = (oid: string, ancestor: string) =>
178
- git
179
- .isDescendent({ fs: nodeFs, dir, oid, ancestor, depth: -1 })
180
- .catch(() => false);
181
+ nativeGit(dir, ["merge-base", "--is-ancestor", ancestor, oid]).then(
182
+ () => true,
183
+ () => false,
184
+ );
181
185
 
182
186
  if (await isDescendent(localSha, remoteSha)) {
183
187
  if (!owned) return { status: "ahead", localSha, remoteSha };
@@ -192,40 +196,44 @@ export async function syncWithNetworkRemote(opts: {
192
196
  if (dirty) return { status: "deferred", localSha, remoteSha };
193
197
 
194
198
  if (behind) {
195
- await git.writeRef({
196
- fs: nodeFs,
197
- dir,
198
- ref: "refs/heads/main",
199
- value: remoteSha,
200
- force: true,
201
- });
202
- await git.checkout({ fs: nodeFs, dir, ref: "main", force: true });
199
+ await nativeGit(dir, ["merge", "--quiet", "--ff-only", remoteSha]);
203
200
  return { status: "pulled", localSha: remoteSha, remoteSha };
204
201
  }
205
202
 
206
203
  // Diverged histories on an owned remote.
207
- try {
208
- const merge = await git.merge({
209
- fs: nodeFs,
210
- dir,
211
- ours: "main",
212
- theirs: remoteSha,
213
- author: opts.author,
214
- committer: opts.author,
215
- fastForward: true,
216
- abortOnConflict: true,
217
- message: `Merge remote ${opts.remoteBranch} into main`,
218
- });
219
- await git.checkout({ fs: nodeFs, dir, ref: "main", force: true });
220
- const mergedSha = merge.oid ?? (await dev.resolveRef("refs/heads/main"));
221
- await push(opts.remoteBranch);
222
- return { status: "merged", localSha: mergedSha, remoteSha: mergedSha };
223
- } catch (err) {
224
- if ((err as { code?: string })?.code !== "MergeConflictError") throw err;
204
+ const merged = await nativeGit(dir, [
205
+ "-c",
206
+ `user.name=${opts.author.name}`,
207
+ "-c",
208
+ `user.email=${opts.author.email}`,
209
+ "merge",
210
+ "--quiet",
211
+ "--no-edit",
212
+ "-m",
213
+ `Merge remote ${opts.remoteBranch} into main`,
214
+ remoteSha,
215
+ ]).then(
216
+ () => true,
217
+ async (error: unknown) => {
218
+ const conflicted = (
219
+ await nativeGit(dir, ["diff", "--name-only", "--diff-filter=U"]).catch(
220
+ () => "",
221
+ )
222
+ ).trim();
223
+ // A background sync never leaves conflict markers behind.
224
+ await nativeGit(dir, ["merge", "--abort"]).catch(() => "");
225
+ if (!conflicted) throw error;
226
+ return false;
227
+ },
228
+ );
229
+ if (!merged) {
225
230
  const rescueBranch = rescueBranchName(opts.now ?? new Date());
226
231
  await push(rescueBranch);
227
232
  return { status: "diverged", localSha, remoteSha, rescueBranch };
228
233
  }
234
+ const mergedSha = await dev.resolveRef("refs/heads/main");
235
+ await push(opts.remoteBranch);
236
+ return { status: "merged", localSha: mergedSha, remoteSha: mergedSha };
229
237
  }
230
238
 
231
239
  /** `work/diverged-YYYY-MM-DD_HH-mm` — groups rescue pushes on the host. */
package/src/network.ts CHANGED
@@ -1,13 +1,22 @@
1
- import nodeFs from "node:fs";
1
+ import { getTracer, withSpan } from "@catamorphic/otel";
2
2
  import { MANAGED_BRANCH_PREFIX } from "@catamorphic/workflow/project-layout";
3
- import git from "isomorphic-git";
4
- import http from "isomorphic-git/http/node";
5
- import { type NativeGitAuth, nativeGit } from "./native-git.js";
3
+ import {
4
+ gitErrorText,
5
+ type NativeGitAuth,
6
+ nativeGit,
7
+ TRANSFER_TIMEOUT_MS,
8
+ } from "./native-git.js";
6
9
  import { isValidRefName } from "./ref-names.js";
7
10
  import type { GitCredentials } from "./types.js";
8
11
 
12
+ const tracer = getTracer("@catamorphic/git");
13
+
9
14
  export interface CloneFromRemoteOptions {
10
- native?: boolean;
15
+ /**
16
+ * The repository is a copy Work manages, not a person's own folder: one
17
+ * branch arrives, as the local `main`, with no remote of its own.
18
+ */
19
+ managed?: boolean;
11
20
  /** Directory that already holds an initialized (empty) git repo. */
12
21
  repoPath: string;
13
22
  url: string;
@@ -16,105 +25,125 @@ export interface CloneFromRemoteOptions {
16
25
  branch?: string;
17
26
  }
18
27
 
19
- function onAuthFor(credentials?: GitCredentials) {
20
- return credentials
21
- ? () => ({
22
- username: credentials.username,
23
- password: credentials.password,
24
- })
25
- : undefined;
28
+ function authFor(opts: {
29
+ url: string;
30
+ credentials?: GitCredentials;
31
+ }): NativeGitAuth | undefined {
32
+ return opts.credentials ? { ...opts.credentials, url: opts.url } : undefined;
26
33
  }
27
34
 
28
35
  /**
29
36
  * Populate a freshly-initialized repo from a network git remote (e.g. a
30
- * GitHub repository). The remote's history lands on the local `main` branch
31
- * regardless of the remote's branch name — catamorphic's internal sync
32
- * (`git-sync`, drafts, checkout seeding) assumes `main` throughout, so the remote
33
- * branch name is only remembered by the caller for push-back.
37
+ * GitHub repository), with the Git program: the history arrives as packs,
38
+ * whatever its size. A person's own folder becomes an ordinary clone on the
39
+ * remote's branch. A copy Work manages receives that one branch as its
40
+ * local `main` regardless of the remote's branch name: Work's internal sync
41
+ * (`git-sync`, drafts, checkout seeding) assumes `main` throughout, so the
42
+ * remote branch name is only remembered by the caller for push-back.
34
43
  *
35
44
  * Returns the checked-out sha and the remote's branch name.
36
45
  */
37
46
  export async function cloneFromRemote(
38
47
  opts: CloneFromRemoteOptions,
39
48
  ): Promise<{ sha: string; remoteBranch: string }> {
40
- if (opts.native) {
41
- const auth = opts.credentials
42
- ? { ...opts.credentials, url: opts.url }
43
- : undefined;
44
- await nativeGit(opts.repoPath, ["remote", "add", "origin", opts.url]);
45
- await nativeGit(opts.repoPath, ["fetch", "--tags", "origin"], auth);
46
- const remoteBranch =
47
- opts.branch ??
48
- (
49
+ return withSpan(
50
+ {
51
+ tracer,
52
+ name: "git.clone",
53
+ attributes: { "catamorphic.git.managed": opts.managed ?? false },
54
+ },
55
+ async () => {
56
+ const auth = authFor(opts);
57
+ const transfer = { timeoutMs: TRANSFER_TIMEOUT_MS };
58
+ if (!opts.managed) {
59
+ await nativeGit(opts.repoPath, [
60
+ "remote",
61
+ "add",
62
+ "--end-of-options",
63
+ "origin",
64
+ opts.url,
65
+ ]);
49
66
  await nativeGit(
50
67
  opts.repoPath,
51
- ["ls-remote", "--symref", "origin", "HEAD"],
68
+ ["fetch", "--tags", "origin"],
52
69
  auth,
53
- )
54
- ).match(/ref: refs\/heads\/(.+)\tHEAD/)?.[1];
55
- if (!remoteBranch)
56
- throw new Error("The repository has no default branch to check out");
57
- await nativeGit(opts.repoPath, [
58
- "checkout",
59
- "-B",
60
- remoteBranch,
61
- "--track",
62
- `origin/${remoteBranch}`,
63
- ]);
64
- await nativeGit(opts.repoPath, [
65
- "symbolic-ref",
66
- "refs/remotes/origin/HEAD",
67
- `refs/remotes/origin/${remoteBranch}`,
68
- ]);
69
- return {
70
- sha: (await nativeGit(opts.repoPath, ["rev-parse", "HEAD"])).trim(),
71
- remoteBranch,
72
- };
73
- }
74
- await git.addRemote({
75
- fs: nodeFs,
76
- dir: opts.repoPath,
77
- remote: "origin",
78
- url: opts.url,
79
- force: true,
80
- });
81
-
82
- const result = await git.fetch({
83
- fs: nodeFs,
84
- http,
85
- dir: opts.repoPath,
86
- remote: "origin",
87
- ...(opts.branch ? { ref: opts.branch } : {}),
88
- singleBranch: true,
89
- tags: false,
90
- onAuth: onAuthFor(opts.credentials),
91
- });
92
-
93
- const sha = result.fetchHead;
94
- if (!sha) {
95
- throw new Error(`Remote '${opts.url}' has no commits to clone`);
96
- }
97
- const remoteBranch =
98
- opts.branch ??
99
- (result.defaultBranch
100
- ? result.defaultBranch.replace(/^refs\/heads\//, "")
101
- : "main");
102
-
103
- await git.writeRef({
104
- fs: nodeFs,
105
- dir: opts.repoPath,
106
- ref: "refs/heads/main",
107
- value: sha,
108
- force: true,
109
- });
110
- await git.checkout({
111
- fs: nodeFs,
112
- dir: opts.repoPath,
113
- ref: "main",
114
- force: true,
115
- });
116
-
117
- return { sha, remoteBranch };
70
+ transfer,
71
+ );
72
+ const remoteBranch =
73
+ opts.branch ??
74
+ (
75
+ await nativeGit(
76
+ opts.repoPath,
77
+ ["ls-remote", "--symref", "origin", "HEAD"],
78
+ auth,
79
+ )
80
+ ).match(/ref: refs\/heads\/(.+)\tHEAD/)?.[1];
81
+ if (!remoteBranch)
82
+ throw new Error("The repository has no default branch to check out");
83
+ await nativeGit(opts.repoPath, [
84
+ "checkout",
85
+ "-B",
86
+ remoteBranch,
87
+ "--track",
88
+ `origin/${remoteBranch}`,
89
+ ]);
90
+ await nativeGit(opts.repoPath, [
91
+ "symbolic-ref",
92
+ "refs/remotes/origin/HEAD",
93
+ `refs/remotes/origin/${remoteBranch}`,
94
+ ]);
95
+ return {
96
+ sha: (await nativeGit(opts.repoPath, ["rev-parse", "HEAD"])).trim(),
97
+ remoteBranch,
98
+ };
99
+ }
100
+ const remoteBranch =
101
+ opts.branch ??
102
+ (
103
+ await nativeGit(
104
+ opts.repoPath,
105
+ ["ls-remote", "--symref", "--end-of-options", opts.url, "HEAD"],
106
+ auth,
107
+ ).catch((error: unknown) => {
108
+ throw new Error(
109
+ `Could not reach the repository to clone it: ${gitErrorText(error)}`,
110
+ );
111
+ })
112
+ ).match(/ref: refs\/heads\/(.+)\tHEAD/)?.[1];
113
+ if (!remoteBranch || !isValidRefName(remoteBranch))
114
+ throw new Error(`Remote '${opts.url}' has no commits to clone`);
115
+ await nativeGit(
116
+ opts.repoPath,
117
+ [
118
+ "fetch",
119
+ "--quiet",
120
+ "--no-tags",
121
+ "--no-write-fetch-head",
122
+ // The copy is new and empty: its unborn `main` is what arrives.
123
+ "--update-head-ok",
124
+ "--end-of-options",
125
+ opts.url,
126
+ `+refs/heads/${remoteBranch}:refs/heads/main`,
127
+ ],
128
+ auth,
129
+ transfer,
130
+ ).catch((error: unknown) => {
131
+ throw new Error(
132
+ `Could not clone '${remoteBranch}' of the repository: ${gitErrorText(error)}`,
133
+ );
134
+ });
135
+ await nativeGit(
136
+ opts.repoPath,
137
+ ["reset", "--quiet", "--hard", "refs/heads/main"],
138
+ undefined,
139
+ transfer,
140
+ );
141
+ return {
142
+ sha: (await nativeGit(opts.repoPath, ["rev-parse", "HEAD"])).trim(),
143
+ remoteBranch,
144
+ };
145
+ },
146
+ );
118
147
  }
119
148
 
120
149
  /**
@@ -183,7 +212,6 @@ export function assertPushAllowed(input: {
183
212
  */
184
213
  export async function pushToRemote(opts: {
185
214
  repoPath: string;
186
- native?: boolean;
187
215
  url: string;
188
216
  credentials?: GitCredentials;
189
217
  /** Who created the remote: attached remotes only accept Work's branches. */
@@ -195,7 +223,7 @@ export async function pushToRemote(opts: {
195
223
  force?: boolean;
196
224
  /**
197
225
  * Replace the branch only while it still holds `expected` (null: only
198
- * while it does not exist). Native Git only.
226
+ * while it does not exist).
199
227
  */
200
228
  lease?: { expected: string | null };
201
229
  }): Promise<void> {
@@ -215,7 +243,7 @@ export async function pushToRemote(opts: {
215
243
  });
216
244
  if (opts.lease) {
217
245
  const expected = opts.lease.expected ?? "";
218
- if (!opts.native || (expected && !/^[0-9a-f]{40,64}$/.test(expected)))
246
+ if (expected && !/^[0-9a-f]{40,64}$/.test(expected))
219
247
  throw new RemotePushRefusedError(
220
248
  remoteBranch,
221
249
  "a push with a lease names the commit it replaces.",
@@ -232,29 +260,20 @@ export async function pushToRemote(opts: {
232
260
  });
233
261
  return;
234
262
  }
235
- if (opts.native) {
236
- await nativeGit(
237
- opts.repoPath,
238
- [
239
- "push",
240
- ...(opts.force ? ["--force-with-lease"] : []),
241
- opts.url,
242
- `${ref}:refs/heads/${remoteBranch}`,
243
- ],
244
- opts.credentials ? { ...opts.credentials, url: opts.url } : undefined,
245
- );
246
- return;
247
- }
248
- await git.push({
249
- fs: nodeFs,
250
- http,
251
- dir: opts.repoPath,
252
- url: opts.url,
253
- ref,
254
- remoteRef: `refs/heads/${remoteBranch}`,
255
- force: opts.force ?? false,
256
- onAuth: onAuthFor(opts.credentials),
257
- });
263
+ await nativeGit(
264
+ opts.repoPath,
265
+ [
266
+ "push",
267
+ "--quiet",
268
+ // No lease names what a plain force replaces: a remote given by its
269
+ // address has no tracking ref to compare with.
270
+ ...(opts.force ? ["--force"] : []),
271
+ "--end-of-options",
272
+ opts.url,
273
+ `${ref}:refs/heads/${remoteBranch}`,
274
+ ],
275
+ authFor(opts),
276
+ );
258
277
  }
259
278
 
260
279
  function pushWithLease(input: {
@@ -272,6 +291,7 @@ function pushWithLease(input: {
272
291
  "--porcelain",
273
292
  "--no-follow-tags",
274
293
  `--force-with-lease=${input.target}:${input.expected}`,
294
+ "--end-of-options",
275
295
  input.url,
276
296
  `${input.ref}:${input.target}`,
277
297
  ],
@@ -327,7 +347,7 @@ export async function pushOwnBranch(opts: {
327
347
  const target = `refs/heads/${remoteBranch}`;
328
348
  const listed = await nativeGit(
329
349
  opts.repoPath,
330
- ["ls-remote", "--symref", opts.url, "HEAD", target],
350
+ ["ls-remote", "--symref", "--end-of-options", opts.url, "HEAD", target],
331
351
  auth,
332
352
  );
333
353
  const refs = new Map<string, string>();
@@ -426,8 +446,8 @@ function isStaleLease(error: unknown): boolean {
426
446
  }
427
447
 
428
448
  /**
429
- * Fetch a branch from a network remote into a tracking ref without touching
430
- * the working tree. Returns the fetched sha (null when the remote branch does
449
+ * Fetch a branch from a network remote without touching the working tree
450
+ * or any branch. Returns the fetched sha (null when the remote branch does
431
451
  * not exist).
432
452
  */
433
453
  export async function fetchFromRemote(opts: {
@@ -436,37 +456,41 @@ export async function fetchFromRemote(opts: {
436
456
  credentials?: GitCredentials;
437
457
  branch: string;
438
458
  }): Promise<{ sha: string | null }> {
439
- // Disposable origin snapshots have no network remote/refspec. Keep this
440
- // tracking namespace separate from the host's internal origin.
441
- const remote = "catamorphic-network";
442
- await git.addRemote({
443
- fs: nodeFs,
444
- dir: opts.repoPath,
445
- remote,
446
- url: opts.url,
447
- force: true,
448
- });
449
- try {
450
- const result = await git.fetch({
451
- fs: nodeFs,
452
- http,
453
- dir: opts.repoPath,
454
- url: opts.url,
455
- remote,
456
- ref: opts.branch,
457
- remoteRef: opts.branch,
458
- singleBranch: true,
459
- tags: false,
460
- onAuth: onAuthFor(opts.credentials),
461
- });
462
- return { sha: result.fetchHead };
463
- } catch (err) {
464
- if (
465
- err instanceof git.Errors.NotFoundError &&
466
- err.data.what === opts.branch
467
- ) {
468
- return { sha: null };
469
- }
470
- throw err;
471
- }
459
+ if (!isValidRefName(opts.branch) || opts.branch.startsWith("-"))
460
+ throw new Error(`'${opts.branch}' is not a branch name`);
461
+ const auth = authFor(opts);
462
+ const listed = (
463
+ await nativeGit(
464
+ opts.repoPath,
465
+ ["ls-remote", "--end-of-options", opts.url, `refs/heads/${opts.branch}`],
466
+ auth,
467
+ )
468
+ ).trim();
469
+ const sha = listed.split(/\s+/)[0];
470
+ if (!sha || !/^[0-9a-f]{40}$|^[0-9a-f]{64}$/.test(sha)) return { sha: null };
471
+ // Kept under a ref of Work's own, apart from the host's internal origin,
472
+ // so what was fetched stays reachable.
473
+ await nativeGit(
474
+ opts.repoPath,
475
+ [
476
+ "fetch",
477
+ "--quiet",
478
+ "--no-tags",
479
+ "--no-write-fetch-head",
480
+ "--end-of-options",
481
+ opts.url,
482
+ `+refs/heads/${opts.branch}:refs/work/network/${opts.branch}`,
483
+ ],
484
+ auth,
485
+ { timeoutMs: TRANSFER_TIMEOUT_MS },
486
+ );
487
+ return {
488
+ sha: (
489
+ await nativeGit(opts.repoPath, [
490
+ "rev-parse",
491
+ "--verify",
492
+ `refs/work/network/${opts.branch}^{commit}`,
493
+ ])
494
+ ).trim(),
495
+ };
472
496
  }