@teambit/ci 1.0.494 → 1.0.495

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.
@@ -1,5 +1,5 @@
1
1
  ;
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.git_ci@1.0.494/dist/ci.docs.mdx';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.git_ci@1.0.495/dist/ci.docs.mdx';
3
3
 
4
4
  export const compositions = [];
5
5
  export const overview = [overview_0];
@@ -91,6 +91,47 @@ export declare function deleteBranchArgs(branch: string, expectedTipSha: string)
91
91
  * direction — the only consequence is reporting a branch as kept rather than as a failed delete.
92
92
  */
93
93
  export declare function isStaleLeaseRejection(message: string): boolean;
94
+ /**
95
+ * Whether a failed push was a plain non-fast-forward rejection: a concurrent run already advanced
96
+ * `branch`, so ours is now stale. `commitAllAndPush` never uses `--force-with-lease`, yet a race can
97
+ * still surface the SAME wording `isStaleLeaseRejection` matches: git's ref-update transaction rejects
98
+ * an ordinary push exactly like a lease refusal once the remote's ref changed underneath it (confirmed
99
+ * empirically on the local/file transport this repo's e2e remotes use — "cannot lock ref … is at X but
100
+ * expected Y" — no lease involved). A GitHub-style remote instead rejects the ref with a
101
+ * `[rejected] … (fetch first)` or `(non-fast-forward)` line. That line's layout varies: simple-git
102
+ * appends `--porcelain` to every push, so the real shape is tab-separated
103
+ * (`!\tHEAD:refs/heads/x\t[rejected] (fetch first)`), NOT the human `! [rejected] …` — match the
104
+ * `[rejected]` token plus the reason, never the whitespace around them. `[remote rejected]` (a server
105
+ * hook decline, e.g. a protected branch) does not contain the bare `[rejected]` token and is excluded:
106
+ * that is a real problem to surface, not a race to swallow.
107
+ */
108
+ export declare function isNonFastForwardRejection(message: string): boolean;
109
+ /**
110
+ * Whether a rejected plain push was a CONFIRMED race: the wording matches a non-fast-forward rejection
111
+ * AND a re-fetch shows `branch` actually moved off `baseSha` — the tip the rejected push was based on.
112
+ * The wording alone is not proof: the regexes are deliberately broad, so a PERSISTENT, unrelated push
113
+ * failure (bad credentials, a flaky transport) could repeat the same wording forever; unconfirmed
114
+ * answers 'not-a-race' and the caller fails loud. A failed re-fetch (`undefined` tip) is UNKNOWN, not
115
+ * confirmation — never treat not knowing as proof of a race. The one `remoteMoved` expression also
116
+ * covers a brand-new branch (`baseSha === undefined`): a defined tip already proves the branch now
117
+ * exists on the remote. `refetchTip` is injectable so callers stay unit-testable without a real remote.
118
+ */
119
+ export declare function confirmPushRace(branch: string, baseSha: string | undefined, message: string, refetchTip?: (branch: string) => Promise<string | undefined>): Promise<'confirmed-race' | 'not-a-race'>;
120
+ /**
121
+ * Strip URL userinfo (`https://user:token@host` → `https://***@host`) from a git message before it
122
+ * reaches a log or a summary: git prints the remote URL in push errors, and a remote may embed
123
+ * credentials. Over-redaction is the safe direction — `ssh://git@host` loses nothing that matters.
124
+ */
125
+ export declare function redactUrlCredentials(text: string): string;
126
+ /**
127
+ * Move the local `branch` back to `origin/<branch>`, dropping unpushed commits — the cleanup after a
128
+ * lost push race, so the orphan commit cannot trip `checkoutPristine`'s guard on the clone's next run.
129
+ * `reset --hard` writes the index, so a stale `index.lock` blocks it; the `update-ref` fallback does
130
+ * not touch the index and still moves the ref off the orphan commit (the callers force-clean the tree
131
+ * afterwards, in `restoreWorkspace`). Returns the failure message instead of throwing: the drop is
132
+ * best-effort, and a failed drop must not escalate a confirmed-benign race.
133
+ */
134
+ export declare function dropLocalBranchToRemoteTip(branch: string): Promise<string | undefined>;
94
135
  /** Whether `origin` has the given branch. Assumes a `git fetch` isn't required (uses `ls-remote`). */
95
136
  export declare function branchExistsOnRemote(branch: string): Promise<boolean>;
96
137
  /**
@@ -11,19 +11,23 @@ exports.checkoutPristine = checkoutPristine;
11
11
  exports.checkoutPristineRestore = checkoutPristineRestore;
12
12
  exports.cleanUntrackedScoped = cleanUntrackedScoped;
13
13
  exports.commitWithIdentity = commitWithIdentity;
14
+ exports.confirmPushRace = confirmPushRace;
14
15
  exports.deleteBranchArgs = deleteBranchArgs;
16
+ exports.dropLocalBranchToRemoteTip = dropLocalBranchToRemoteTip;
15
17
  exports.fetchRemoteHeads = fetchRemoteHeads;
16
18
  exports.gitRepoRoot = gitRepoRoot;
17
19
  exports.gitWithIdentity = gitWithIdentity;
18
20
  exports.identityArgs = identityArgs;
19
21
  exports.isAncestor = isAncestor;
20
22
  exports.isNonContentPath = isNonContentPath;
23
+ exports.isNonFastForwardRejection = isNonFastForwardRejection;
21
24
  exports.isStaleLeaseRejection = isStaleLeaseRejection;
22
25
  exports.listRemoteBranches = listRemoteBranches;
23
26
  exports.localBranchExists = localBranchExists;
24
27
  exports.parseLsRemoteSymref = parseLsRemoteSymref;
25
28
  exports.parseOriginHeadRef = parseOriginHeadRef;
26
29
  exports.realGitRaw = exports.realGitConfigIO = void 0;
30
+ exports.redactUrlCredentials = redactUrlCredentials;
27
31
  exports.refetchBranchTip = refetchBranchTip;
28
32
  exports.remoteHeadBranch = remoteHeadBranch;
29
33
  exports.resolveGitIdentity = resolveGitIdentity;
@@ -212,6 +216,73 @@ function isStaleLeaseRejection(message) {
212
216
  return /stale info|force-with-lease|but expected|incorrect old value/i.test(message);
213
217
  }
214
218
 
219
+ /**
220
+ * Whether a failed push was a plain non-fast-forward rejection: a concurrent run already advanced
221
+ * `branch`, so ours is now stale. `commitAllAndPush` never uses `--force-with-lease`, yet a race can
222
+ * still surface the SAME wording `isStaleLeaseRejection` matches: git's ref-update transaction rejects
223
+ * an ordinary push exactly like a lease refusal once the remote's ref changed underneath it (confirmed
224
+ * empirically on the local/file transport this repo's e2e remotes use — "cannot lock ref … is at X but
225
+ * expected Y" — no lease involved). A GitHub-style remote instead rejects the ref with a
226
+ * `[rejected] … (fetch first)` or `(non-fast-forward)` line. That line's layout varies: simple-git
227
+ * appends `--porcelain` to every push, so the real shape is tab-separated
228
+ * (`!\tHEAD:refs/heads/x\t[rejected] (fetch first)`), NOT the human `! [rejected] …` — match the
229
+ * `[rejected]` token plus the reason, never the whitespace around them. `[remote rejected]` (a server
230
+ * hook decline, e.g. a protected branch) does not contain the bare `[rejected]` token and is excluded:
231
+ * that is a real problem to surface, not a race to swallow.
232
+ */
233
+ function isNonFastForwardRejection(message) {
234
+ if (isStaleLeaseRejection(message)) return true;
235
+ return /\[rejected\]/.test(message) && /fetch first|non-fast-forward/i.test(message);
236
+ }
237
+
238
+ /**
239
+ * Whether a rejected plain push was a CONFIRMED race: the wording matches a non-fast-forward rejection
240
+ * AND a re-fetch shows `branch` actually moved off `baseSha` — the tip the rejected push was based on.
241
+ * The wording alone is not proof: the regexes are deliberately broad, so a PERSISTENT, unrelated push
242
+ * failure (bad credentials, a flaky transport) could repeat the same wording forever; unconfirmed
243
+ * answers 'not-a-race' and the caller fails loud. A failed re-fetch (`undefined` tip) is UNKNOWN, not
244
+ * confirmation — never treat not knowing as proof of a race. The one `remoteMoved` expression also
245
+ * covers a brand-new branch (`baseSha === undefined`): a defined tip already proves the branch now
246
+ * exists on the remote. `refetchTip` is injectable so callers stay unit-testable without a real remote.
247
+ */
248
+ async function confirmPushRace(branch, baseSha, message, refetchTip = refetchBranchTip) {
249
+ if (!isNonFastForwardRejection(message)) return 'not-a-race';
250
+ const currentTip = await refetchTip(branch);
251
+ const remoteMoved = currentTip !== undefined && currentTip !== baseSha;
252
+ return remoteMoved ? 'confirmed-race' : 'not-a-race';
253
+ }
254
+
255
+ /**
256
+ * Strip URL userinfo (`https://user:token@host` → `https://***@host`) from a git message before it
257
+ * reaches a log or a summary: git prints the remote URL in push errors, and a remote may embed
258
+ * credentials. Over-redaction is the safe direction — `ssh://git@host` loses nothing that matters.
259
+ */
260
+ function redactUrlCredentials(text) {
261
+ return text.replace(/\/\/[^\s@/]+@/g, '//***@');
262
+ }
263
+
264
+ /**
265
+ * Move the local `branch` back to `origin/<branch>`, dropping unpushed commits — the cleanup after a
266
+ * lost push race, so the orphan commit cannot trip `checkoutPristine`'s guard on the clone's next run.
267
+ * `reset --hard` writes the index, so a stale `index.lock` blocks it; the `update-ref` fallback does
268
+ * not touch the index and still moves the ref off the orphan commit (the callers force-clean the tree
269
+ * afterwards, in `restoreWorkspace`). Returns the failure message instead of throwing: the drop is
270
+ * best-effort, and a failed drop must not escalate a confirmed-benign race.
271
+ */
272
+ async function dropLocalBranchToRemoteTip(branch) {
273
+ try {
274
+ await _git().git.raw(['reset', '--hard', `origin/${branch}`]);
275
+ return undefined;
276
+ } catch (resetErr) {
277
+ try {
278
+ await _git().git.raw(['update-ref', `refs/heads/${branch}`, `refs/remotes/origin/${branch}`]);
279
+ return undefined;
280
+ } catch {
281
+ return String(resetErr?.message || resetErr);
282
+ }
283
+ }
284
+ }
285
+
215
286
  /** Whether `origin` has the given branch. Assumes a `git fetch` isn't required (uses `ls-remote`). */
216
287
  async function branchExistsOnRemote(branch) {
217
288
  const out = await _git().git.raw(['ls-remote', '--heads', 'origin', branch]);
@@ -1 +1 @@
1
- {"version":3,"names":["_bitError","data","require","_git","_syncConfig","_excluded","_objectWithoutProperties","e","t","o","r","i","_objectWithoutPropertiesLoose","Object","getOwnPropertySymbols","n","length","indexOf","propertyIsEnumerable","call","hasOwnProperty","SYNC_EXCLUDED_PATHS","exports","realGitRaw","args","git","raw","cleanUntrackedScoped","run","flatMap","path","assertCheckoutableBranch","branch","problem","validateBranchName","BitError","checkoutPristine","startPoint","reload","localBranchExists","containedIn","String","trim","Error","out","catch","checkoutPristineRestore","undefined","addAllExceptScopeAndModules","stageAll","map","isNonContentPath","some","excluded","startsWith","ALL_HEADS_REFSPEC","fetchRemoteHeads","singleHeadRefspec","refetchBranchTip","deleteBranchArgs","expectedTipSha","isStaleLeaseRejection","message","test","branchExistsOnRemote","listRemoteBranches","prefix","split","line","filter","ref","Boolean","slice","isAncestor","maybeAncestor","descendant","ancestorSha","revparse","mergeBase","ORIGIN_HEAD_REF_PREFIX","parseOriginHeadRef","symbolicRefOutput","LS_REMOTE_SYMREF_PREFIX","parseLsRemoteSymref","lsRemoteOutput","find","l","name","remoteHeadBranch","gitRepoRoot","root","realGitConfigIO","get","key","then","DEFAULT_GIT_USER_NAME","DEFAULT_GIT_USER_EMAIL","resolveGitIdentity","io","env","process","GIT_USER_NAME","email","GIT_USER_EMAIL","identityArgs","identity","gitWithIdentity","deps","commitWithIdentity","opts","extraArgs"],"sources":["git-ops.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { git } from '../git';\nimport { validateBranchName } from './sync-config';\n\n/**\n * Git primitives shared by the lane and main sync executors; each encodes a decision that must stay\n * identical on both paths.\n */\n\n/** paths the sync executors never treat as workspace content — see `cleanUntrackedScoped` */\nexport const SYNC_EXCLUDED_PATHS = ['.bit', 'node_modules'];\n\n/**\n * How a raw git invocation is run, injectable so a helper whose whole content is its argv can be unit\n * tested without a repository. Production always uses {@link realGitRaw}.\n */\nexport type GitArgsRunner = (args: string[]) => Promise<unknown>;\n\nexport const realGitRaw: GitArgsRunner = (args) => git.raw(args);\n\n/**\n * Remove untracked files, leaving the local bit scope and installed packages alone. No `-x` (ignored\n * files stay), and `.bit` / `node_modules` are excluded explicitly — without that, the clean deletes\n * the local scope in a workspace whose `.gitignore` lacks Bit's block.\n */\nexport async function cleanUntrackedScoped(run: GitArgsRunner = realGitRaw): Promise<void> {\n await run(['clean', '-fd', ...SYNC_EXCLUDED_PATHS.flatMap((path) => ['-e', path])]);\n}\n\n/**\n * Refuse a branch name git would read as an option or reject as a ref. Not every branch reaching the\n * checkout comes from validated config: the default branch is derived from the remote\n * (`getDefaultBranchName`), so the primitive that builds the argv is where the guard belongs — every\n * caller inherits it.\n */\nexport function assertCheckoutableBranch(branch: string): void {\n const problem = validateBranchName(branch);\n if (problem) {\n throw new BitError(\n `bit ci sync cannot check out \"${branch}\": ${problem}. Rename the branch, or set the intended name ` +\n `explicitly in the \"teambit.git/ci\" sync config.`\n );\n }\n}\n\n/**\n * Put the working tree on `branch` holding nothing but that commit's content, then make the workspace\n * re-read the checked-out `.bitmap`. Order matters: `checkout -f` (leftover tracked changes must not\n * abort the target), then the scoped clean (a forced checkout leaves untracked files in place, and\n * every commit path stages with `-A`), then the reload so it reads the pristine tree. With\n * `startPoint`, `-B` creates-or-resets the branch — refused when the local branch holds commits no\n * remote contains, because moving it would orphan unpushed work; the predicate is remote containment,\n * not start-point ancestry (a fully pushed tip loses nothing in either legitimate reset shape).\n */\nexport async function checkoutPristine(\n branch: string,\n startPoint: string | undefined,\n reload: () => Promise<void>,\n run: GitArgsRunner = realGitRaw\n): Promise<void> {\n assertCheckoutableBranch(branch);\n if (startPoint && (await localBranchExists(branch, run))) {\n const containedIn = String((await run(['branch', '-r', '--contains', `refs/heads/${branch}`])) ?? '').trim();\n if (!containedIn) {\n throw new Error(\n `local branch \"${branch}\" has commits that no remote branch contains — resetting it would ` +\n `orphan them (recoverable only from the reflog). Push or back up the local branch, delete ` +\n `it, or run from a clean checkout`\n );\n }\n }\n await run(startPoint ? ['checkout', '-f', '-B', branch, startPoint] : ['checkout', '-f', branch]);\n await cleanUntrackedScoped(run);\n await reload();\n}\n\n/**\n * Whether the branch exists locally. Judged by output, never by whether the call threw: simple-git's\n * `raw` resolves with empty output on some non-zero exits instead of rejecting.\n */\nexport async function localBranchExists(branch: string, run: GitArgsRunner = realGitRaw): Promise<boolean> {\n const out = await run(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`]).catch(() => '');\n return String(out ?? '').trim().length > 0;\n}\n\n/**\n * `checkoutPristine` for the restore paths: a start point only when the branch is absent locally\n * (detached-HEAD/single-branch checkouts) — passing `origin/<branch>` when it exists would `-B`-reset\n * the developer's default branch and discard their unpushed commits.\n */\nexport async function checkoutPristineRestore(\n branch: string,\n reload: () => Promise<void>,\n run: GitArgsRunner = realGitRaw\n): Promise<void> {\n const startPoint = (await localBranchExists(branch, run)) ? undefined : `origin/${branch}`;\n await checkoutPristine(branch, startPoint, reload, run);\n}\n\n/**\n * Stage every change except `.bit` / `node_modules` (a bare `add -A` would commit the local scope when\n * `.gitignore` lacks Bit's block). The `:(exclude)` pathspecs make git skip those trees instead of\n * staging them for a reset to undo; `git add` refuses them when a named path IS ignored — the case where\n * the traversal is already cheap — so the add-then-reset pair is the fallback. Both leave the same index,\n * and `git reset -- <paths>` is a no-op for paths absent from it, so neither fallback command can fail.\n */\nexport async function addAllExceptScopeAndModules(run: GitArgsRunner = realGitRaw): Promise<void> {\n const stageAll = ['add', '-A', '--', '.'];\n try {\n await run([...stageAll, ...SYNC_EXCLUDED_PATHS.map((path) => `:(exclude)${path}`)]);\n } catch {\n await run(stageAll);\n await run(['reset', '-q', '--', ...SYNC_EXCLUDED_PATHS]);\n }\n}\n\n/**\n * Whether a `git status` path is one the sync executors never treat as workspace content. Applied\n * everywhere a status is interpreted — otherwise `.bit`/`node_modules` files count as drift when\n * `.gitignore` lacks Bit's block.\n */\nexport function isNonContentPath(path: string): boolean {\n return SYNC_EXCLUDED_PATHS.some((excluded) => path === excluded || path.startsWith(`${excluded}/`));\n}\n\n/**\n * The refspec every sync fetch passes **explicitly**, overriding whatever `remote.origin.fetch` this\n * checkout was configured with.\n */\nexport const ALL_HEADS_REFSPEC = '+refs/heads/*:refs/remotes/origin/*';\n\n/**\n * Fetch `origin` so every branch it has is available as `refs/remotes/origin/<branch>`. A bare fetch\n * honours the checkout's configured `remote.origin.fetch`, which in a single-branch clone updates\n * exactly one ref while enumeration (`ls-remote`) sees every branch; an explicit refspec overrides the\n * config. Does not make shallow clones work — depth is a different axis.\n */\nexport async function fetchRemoteHeads(run: GitArgsRunner = realGitRaw): Promise<void> {\n await run(['fetch', 'origin', ALL_HEADS_REFSPEC]);\n}\n\n/** Refspec that updates exactly one remote-tracking ref — a mid-run re-read of a single branch. */\nexport function singleHeadRefspec(branch: string): string {\n return `+refs/heads/${branch}:refs/remotes/origin/${branch}`;\n}\n\n/**\n * `origin/<branch>`'s tip as the remote has it NOW: every other ref a run reads comes from one fetch at\n * its start. Undefined when the branch is gone or unreadable — never a stale sha, because the answer\n * decides whether a branch deletion is still safe.\n */\nexport async function refetchBranchTip(branch: string, run: GitArgsRunner = realGitRaw): Promise<string | undefined> {\n try {\n await run(['fetch', 'origin', singleHeadRefspec(branch)]);\n const out = await run(['rev-parse', `refs/remotes/origin/${branch}`]);\n return String(out ?? '').trim() || undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * `git push` argv that deletes a remote branch only while its tip is still `expectedTipSha`. Full\n * `:refs/heads/<b>` refspec so the branch name can never be read as an option; the lease makes the server\n * itself refuse a racing update rather than lose it.\n */\nexport function deleteBranchArgs(branch: string, expectedTipSha: string): string[] {\n return ['origin', `--force-with-lease=refs/heads/${branch}:${expectedTipSha}`, `:refs/heads/${branch}`];\n}\n\n/**\n * Whether a failed push was the lease refusing. The wording varies by git version and transport:\n * \"stale info\" (client-side check), \"is at X but expected Y\" (receive-pack), and \"incorrect old value\n * provided\" (the local/file transport, which is what CI's e2e remotes use). Over-matching is the safe\n * direction — the only consequence is reporting a branch as kept rather than as a failed delete.\n */\nexport function isStaleLeaseRejection(message: string): boolean {\n return /stale info|force-with-lease|but expected|incorrect old value/i.test(message);\n}\n\n/** Whether `origin` has the given branch. Assumes a `git fetch` isn't required (uses `ls-remote`). */\nexport async function branchExistsOnRemote(branch: string): Promise<boolean> {\n const out = await git.raw(['ls-remote', '--heads', 'origin', branch]);\n return out.trim().length > 0;\n}\n\n/**\n * Every branch `origin` has, by short name. `ls-remote` rather than `git branch -r` so the answer\n * cannot be narrowed by the checkout's refspec or staleness.\n */\nexport async function listRemoteBranches(): Promise<string[]> {\n const out = await git.raw(['ls-remote', '--heads', 'origin']);\n const prefix = 'refs/heads/';\n return out\n .split('\\n')\n .map((line) => line.split('\\t')[1]?.trim())\n .filter((ref): ref is string => Boolean(ref && ref.startsWith(prefix)))\n .map((ref) => ref.slice(prefix.length));\n}\n\n/**\n * Is `maybeAncestor` reachable from `descendant` (true for identical commits)? Not `merge-base\n * --is-ancestor`: it answers via the exit code, and simple-git's `raw` resolves on exit 1, so \"not an\n * ancestor\" would read as yes. Throws when the commits share no history or a revision cannot resolve.\n */\nexport async function isAncestor(maybeAncestor: string, descendant: string): Promise<boolean> {\n const ancestorSha = (await git.revparse([maybeAncestor])).trim();\n const mergeBase = (await git.raw(['merge-base', maybeAncestor, descendant])).trim();\n if (!ancestorSha || !mergeBase) throw new Error(`could not compare ${maybeAncestor} against ${descendant}`);\n return ancestorSha === mergeBase;\n}\n\n/** The prefix `git symbolic-ref refs/remotes/origin/HEAD` puts in front of the default branch name. */\nexport const ORIGIN_HEAD_REF_PREFIX = 'refs/remotes/origin/';\n\n/**\n * The default branch name out of `git symbolic-ref refs/remotes/origin/HEAD` output, or undefined for\n * an unrecognised shape. Strips the prefix; never splits on `/` — branch names may contain slashes\n * (`release/main`), and truncating would protect the wrong branch.\n */\nexport function parseOriginHeadRef(symbolicRefOutput: string): string | undefined {\n const ref = symbolicRefOutput.trim();\n if (!ref.startsWith(ORIGIN_HEAD_REF_PREFIX)) return undefined;\n return ref.slice(ORIGIN_HEAD_REF_PREFIX.length) || undefined;\n}\n\n/** The prefix a symref answer from `git ls-remote --symref origin HEAD` puts before the branch name. */\nconst LS_REMOTE_SYMREF_PREFIX = 'ref: refs/heads/';\n\n/**\n * The default branch name out of `git ls-remote --symref origin HEAD` output, or undefined when no\n * symref line is present (some servers omit it). Same slash discipline as {@link parseOriginHeadRef}.\n */\nexport function parseLsRemoteSymref(lsRemoteOutput: string): string | undefined {\n const line = lsRemoteOutput.split('\\n').find((l) => l.startsWith(LS_REMOTE_SYMREF_PREFIX));\n if (!line) return undefined;\n const name = line.slice(LS_REMOTE_SYMREF_PREFIX.length).split('\\t')[0].trim();\n return name || undefined;\n}\n\n/**\n * The remote's own answer for its default branch. Unlike the local `origin/HEAD` symref or enumerating\n * `origin/*`, this cannot be stale or narrowed — only unanswered (undefined hands on to the fallback).\n */\nexport async function remoteHeadBranch(run: GitArgsRunner = realGitRaw): Promise<string | undefined> {\n try {\n const out = await run(['ls-remote', '--symref', 'origin', 'HEAD']);\n return parseLsRemoteSymref(String(out ?? ''));\n } catch {\n return undefined;\n }\n}\n\n/**\n * The git repository's root, or undefined outside a repo. A bit workspace is not necessarily the repo\n * root, and GitHub only discovers workflows at `<repo>/.github/workflows`.\n */\nexport async function gitRepoRoot(): Promise<string | undefined> {\n try {\n const root = (await git.raw(['rev-parse', '--show-toplevel'])).trim();\n return root || undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reading `git config`, injectable so the identity decision can be unit tested without a repository.\n * There is deliberately no writer — see {@link resolveGitIdentity}.\n */\nexport type GitConfigIO = {\n /** the configured value, or undefined when unset (or when git cannot answer) */\n get(key: string): Promise<string | undefined>;\n};\n\nexport const realGitConfigIO: GitConfigIO = {\n get: (key) =>\n git\n .raw(['config', '--get', key])\n .then((out) => (out.trim().length ? out.trim() : undefined))\n // A missing key and \"not a git repository\" both exit non-zero; both mean \"no identity to keep\".\n .catch(() => undefined),\n};\n\n/**\n * The identity the sync commits with when nothing else says otherwise. A contract: the scaffolded\n * workflow templates (`init-scaffold.ts`) and the GitHub Action's defaults must carry the same pair,\n * or the same repository commits under different authors depending on entry point.\n */\nexport const DEFAULT_GIT_USER_NAME = 'bit-sync[bot]';\nexport const DEFAULT_GIT_USER_EMAIL = 'bit-sync[bot]@users.noreply.github.com';\n\nexport type GitIdentity = { name: string; email: string };\n\n/**\n * Who the sync commits as. Read-only on purpose: writing these keys into the repository's config\n * would outlive the run and re-author the developer's own later commits as the bot. Precedence per\n * key: configured git identity > `GIT_USER_NAME`/`GIT_USER_EMAIL` > default.\n */\nexport async function resolveGitIdentity(\n io: GitConfigIO = realGitConfigIO,\n env: NodeJS.ProcessEnv = process.env\n): Promise<GitIdentity> {\n return {\n name: (await io.get('user.name')) || env.GIT_USER_NAME || DEFAULT_GIT_USER_NAME,\n email: (await io.get('user.email')) || env.GIT_USER_EMAIL || DEFAULT_GIT_USER_EMAIL,\n };\n}\n\n/** The `git -c` pair that applies an identity to ONE invocation, leaving the repo's config alone. */\nexport function identityArgs(identity: GitIdentity): string[] {\n return ['-c', `user.name=${identity.name}`, '-c', `user.email=${identity.email}`];\n}\n\nexport type IdentityDeps = { run?: GitArgsRunner; io?: GitConfigIO; env?: NodeJS.ProcessEnv };\n\n/**\n * Run a git command that may author a commit. Every such command needs the identity — a fresh CI\n * checkout has none, and git refuses to commit (\"Please tell me who you are\") without one.\n */\nexport async function gitWithIdentity(args: string[], deps: IdentityDeps = {}): Promise<string> {\n const { run = realGitRaw, io = realGitConfigIO, env = process.env } = deps;\n const identity = await resolveGitIdentity(io, env);\n return String((await run([...identityArgs(identity), ...args])) ?? '');\n}\n\n/** `git commit` under the sync identity; `extraArgs` carries flags such as `--allow-empty`. */\nexport async function commitWithIdentity(\n message: string,\n opts: IdentityDeps & { extraArgs?: string[] } = {}\n): Promise<void> {\n const { extraArgs = [], ...deps } = opts;\n await gitWithIdentity(['commit', '-m', message, ...extraArgs], deps);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmD,MAAAI,SAAA;AAAA,SAAAC,yBAAAC,CAAA,EAAAC,CAAA,gBAAAD,CAAA,iBAAAE,CAAA,EAAAC,CAAA,EAAAC,CAAA,GAAAC,6BAAA,CAAAL,CAAA,EAAAC,CAAA,OAAAK,MAAA,CAAAC,qBAAA,QAAAC,CAAA,GAAAF,MAAA,CAAAC,qBAAA,CAA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/E,GAAG,GAAGL,UAAU;IAAE2E,EAAE,GAAGP,eAAe;IAAEQ,GAAG,GAAGC,OAAO,CAACD;EAAI,CAAC,GAAGQ,IAAI;EAC1E,MAAMF,QAAQ,GAAG,MAAMR,kBAAkB,CAACC,EAAE,EAAEC,GAAG,CAAC;EAClD,OAAO1D,MAAM,CAAC,CAAC,MAAMb,GAAG,CAAC,CAAC,GAAG4E,YAAY,CAACC,QAAQ,CAAC,EAAE,GAAGjF,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AACxE;;AAEA;AACO,eAAeoF,kBAAkBA,CACtC9C,OAAe,EACf+C,IAA6C,GAAG,CAAC,CAAC,EACnC;EACf,MAAM;MAAEC,SAAS,GAAG;IAAY,CAAC,GAAGD,IAAI;IAAbF,IAAI,GAAArG,wBAAA,CAAKuG,IAAI,EAAAxG,SAAA;EACxC,MAAMqG,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE5C,OAAO,EAAE,GAAGgD,SAAS,CAAC,EAAEH,IAAI,CAAC;AACtE","ignoreList":[]}
1
+ {"version":3,"names":["_bitError","data","require","_git","_syncConfig","_excluded","_objectWithoutProperties","e","t","o","r","i","_objectWithoutPropertiesLoose","Object","getOwnPropertySymbols","n","length","indexOf","propertyIsEnumerable","call","hasOwnProperty","SYNC_EXCLUDED_PATHS","exports","realGitRaw","args","git","raw","cleanUntrackedScoped","run","flatMap","path","assertCheckoutableBranch","branch","problem","validateBranchName","BitError","checkoutPristine","startPoint","reload","localBranchExists","containedIn","String","trim","Error","out","catch","checkoutPristineRestore","undefined","addAllExceptScopeAndModules","stageAll","map","isNonContentPath","some","excluded","startsWith","ALL_HEADS_REFSPEC","fetchRemoteHeads","singleHeadRefspec","refetchBranchTip","deleteBranchArgs","expectedTipSha","isStaleLeaseRejection","message","test","isNonFastForwardRejection","confirmPushRace","baseSha","refetchTip","currentTip","remoteMoved","redactUrlCredentials","text","replace","dropLocalBranchToRemoteTip","resetErr","branchExistsOnRemote","listRemoteBranches","prefix","split","line","filter","ref","Boolean","slice","isAncestor","maybeAncestor","descendant","ancestorSha","revparse","mergeBase","ORIGIN_HEAD_REF_PREFIX","parseOriginHeadRef","symbolicRefOutput","LS_REMOTE_SYMREF_PREFIX","parseLsRemoteSymref","lsRemoteOutput","find","l","name","remoteHeadBranch","gitRepoRoot","root","realGitConfigIO","get","key","then","DEFAULT_GIT_USER_NAME","DEFAULT_GIT_USER_EMAIL","resolveGitIdentity","io","env","process","GIT_USER_NAME","email","GIT_USER_EMAIL","identityArgs","identity","gitWithIdentity","deps","commitWithIdentity","opts","extraArgs"],"sources":["git-ops.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { git } from '../git';\nimport { validateBranchName } from './sync-config';\n\n/**\n * Git primitives shared by the lane and main sync executors; each encodes a decision that must stay\n * identical on both paths.\n */\n\n/** paths the sync executors never treat as workspace content — see `cleanUntrackedScoped` */\nexport const SYNC_EXCLUDED_PATHS = ['.bit', 'node_modules'];\n\n/**\n * How a raw git invocation is run, injectable so a helper whose whole content is its argv can be unit\n * tested without a repository. Production always uses {@link realGitRaw}.\n */\nexport type GitArgsRunner = (args: string[]) => Promise<unknown>;\n\nexport const realGitRaw: GitArgsRunner = (args) => git.raw(args);\n\n/**\n * Remove untracked files, leaving the local bit scope and installed packages alone. No `-x` (ignored\n * files stay), and `.bit` / `node_modules` are excluded explicitly — without that, the clean deletes\n * the local scope in a workspace whose `.gitignore` lacks Bit's block.\n */\nexport async function cleanUntrackedScoped(run: GitArgsRunner = realGitRaw): Promise<void> {\n await run(['clean', '-fd', ...SYNC_EXCLUDED_PATHS.flatMap((path) => ['-e', path])]);\n}\n\n/**\n * Refuse a branch name git would read as an option or reject as a ref. Not every branch reaching the\n * checkout comes from validated config: the default branch is derived from the remote\n * (`getDefaultBranchName`), so the primitive that builds the argv is where the guard belongs — every\n * caller inherits it.\n */\nexport function assertCheckoutableBranch(branch: string): void {\n const problem = validateBranchName(branch);\n if (problem) {\n throw new BitError(\n `bit ci sync cannot check out \"${branch}\": ${problem}. Rename the branch, or set the intended name ` +\n `explicitly in the \"teambit.git/ci\" sync config.`\n );\n }\n}\n\n/**\n * Put the working tree on `branch` holding nothing but that commit's content, then make the workspace\n * re-read the checked-out `.bitmap`. Order matters: `checkout -f` (leftover tracked changes must not\n * abort the target), then the scoped clean (a forced checkout leaves untracked files in place, and\n * every commit path stages with `-A`), then the reload so it reads the pristine tree. With\n * `startPoint`, `-B` creates-or-resets the branch — refused when the local branch holds commits no\n * remote contains, because moving it would orphan unpushed work; the predicate is remote containment,\n * not start-point ancestry (a fully pushed tip loses nothing in either legitimate reset shape).\n */\nexport async function checkoutPristine(\n branch: string,\n startPoint: string | undefined,\n reload: () => Promise<void>,\n run: GitArgsRunner = realGitRaw\n): Promise<void> {\n assertCheckoutableBranch(branch);\n if (startPoint && (await localBranchExists(branch, run))) {\n const containedIn = String((await run(['branch', '-r', '--contains', `refs/heads/${branch}`])) ?? '').trim();\n if (!containedIn) {\n throw new Error(\n `local branch \"${branch}\" has commits that no remote branch contains — resetting it would ` +\n `orphan them (recoverable only from the reflog). Push or back up the local branch, delete ` +\n `it, or run from a clean checkout`\n );\n }\n }\n await run(startPoint ? ['checkout', '-f', '-B', branch, startPoint] : ['checkout', '-f', branch]);\n await cleanUntrackedScoped(run);\n await reload();\n}\n\n/**\n * Whether the branch exists locally. Judged by output, never by whether the call threw: simple-git's\n * `raw` resolves with empty output on some non-zero exits instead of rejecting.\n */\nexport async function localBranchExists(branch: string, run: GitArgsRunner = realGitRaw): Promise<boolean> {\n const out = await run(['rev-parse', '--verify', '--quiet', `refs/heads/${branch}`]).catch(() => '');\n return String(out ?? '').trim().length > 0;\n}\n\n/**\n * `checkoutPristine` for the restore paths: a start point only when the branch is absent locally\n * (detached-HEAD/single-branch checkouts) — passing `origin/<branch>` when it exists would `-B`-reset\n * the developer's default branch and discard their unpushed commits.\n */\nexport async function checkoutPristineRestore(\n branch: string,\n reload: () => Promise<void>,\n run: GitArgsRunner = realGitRaw\n): Promise<void> {\n const startPoint = (await localBranchExists(branch, run)) ? undefined : `origin/${branch}`;\n await checkoutPristine(branch, startPoint, reload, run);\n}\n\n/**\n * Stage every change except `.bit` / `node_modules` (a bare `add -A` would commit the local scope when\n * `.gitignore` lacks Bit's block). The `:(exclude)` pathspecs make git skip those trees instead of\n * staging them for a reset to undo; `git add` refuses them when a named path IS ignored — the case where\n * the traversal is already cheap — so the add-then-reset pair is the fallback. Both leave the same index,\n * and `git reset -- <paths>` is a no-op for paths absent from it, so neither fallback command can fail.\n */\nexport async function addAllExceptScopeAndModules(run: GitArgsRunner = realGitRaw): Promise<void> {\n const stageAll = ['add', '-A', '--', '.'];\n try {\n await run([...stageAll, ...SYNC_EXCLUDED_PATHS.map((path) => `:(exclude)${path}`)]);\n } catch {\n await run(stageAll);\n await run(['reset', '-q', '--', ...SYNC_EXCLUDED_PATHS]);\n }\n}\n\n/**\n * Whether a `git status` path is one the sync executors never treat as workspace content. Applied\n * everywhere a status is interpreted — otherwise `.bit`/`node_modules` files count as drift when\n * `.gitignore` lacks Bit's block.\n */\nexport function isNonContentPath(path: string): boolean {\n return SYNC_EXCLUDED_PATHS.some((excluded) => path === excluded || path.startsWith(`${excluded}/`));\n}\n\n/**\n * The refspec every sync fetch passes **explicitly**, overriding whatever `remote.origin.fetch` this\n * checkout was configured with.\n */\nexport const ALL_HEADS_REFSPEC = '+refs/heads/*:refs/remotes/origin/*';\n\n/**\n * Fetch `origin` so every branch it has is available as `refs/remotes/origin/<branch>`. A bare fetch\n * honours the checkout's configured `remote.origin.fetch`, which in a single-branch clone updates\n * exactly one ref while enumeration (`ls-remote`) sees every branch; an explicit refspec overrides the\n * config. Does not make shallow clones work — depth is a different axis.\n */\nexport async function fetchRemoteHeads(run: GitArgsRunner = realGitRaw): Promise<void> {\n await run(['fetch', 'origin', ALL_HEADS_REFSPEC]);\n}\n\n/** Refspec that updates exactly one remote-tracking ref — a mid-run re-read of a single branch. */\nexport function singleHeadRefspec(branch: string): string {\n return `+refs/heads/${branch}:refs/remotes/origin/${branch}`;\n}\n\n/**\n * `origin/<branch>`'s tip as the remote has it NOW: every other ref a run reads comes from one fetch at\n * its start. Undefined when the branch is gone or unreadable — never a stale sha, because the answer\n * decides whether a branch deletion is still safe.\n */\nexport async function refetchBranchTip(branch: string, run: GitArgsRunner = realGitRaw): Promise<string | undefined> {\n try {\n await run(['fetch', 'origin', singleHeadRefspec(branch)]);\n const out = await run(['rev-parse', `refs/remotes/origin/${branch}`]);\n return String(out ?? '').trim() || undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * `git push` argv that deletes a remote branch only while its tip is still `expectedTipSha`. Full\n * `:refs/heads/<b>` refspec so the branch name can never be read as an option; the lease makes the server\n * itself refuse a racing update rather than lose it.\n */\nexport function deleteBranchArgs(branch: string, expectedTipSha: string): string[] {\n return ['origin', `--force-with-lease=refs/heads/${branch}:${expectedTipSha}`, `:refs/heads/${branch}`];\n}\n\n/**\n * Whether a failed push was the lease refusing. The wording varies by git version and transport:\n * \"stale info\" (client-side check), \"is at X but expected Y\" (receive-pack), and \"incorrect old value\n * provided\" (the local/file transport, which is what CI's e2e remotes use). Over-matching is the safe\n * direction — the only consequence is reporting a branch as kept rather than as a failed delete.\n */\nexport function isStaleLeaseRejection(message: string): boolean {\n return /stale info|force-with-lease|but expected|incorrect old value/i.test(message);\n}\n\n/**\n * Whether a failed push was a plain non-fast-forward rejection: a concurrent run already advanced\n * `branch`, so ours is now stale. `commitAllAndPush` never uses `--force-with-lease`, yet a race can\n * still surface the SAME wording `isStaleLeaseRejection` matches: git's ref-update transaction rejects\n * an ordinary push exactly like a lease refusal once the remote's ref changed underneath it (confirmed\n * empirically on the local/file transport this repo's e2e remotes use — \"cannot lock ref … is at X but\n * expected Y\" — no lease involved). A GitHub-style remote instead rejects the ref with a\n * `[rejected] … (fetch first)` or `(non-fast-forward)` line. That line's layout varies: simple-git\n * appends `--porcelain` to every push, so the real shape is tab-separated\n * (`!\\tHEAD:refs/heads/x\\t[rejected] (fetch first)`), NOT the human `! [rejected] …` — match the\n * `[rejected]` token plus the reason, never the whitespace around them. `[remote rejected]` (a server\n * hook decline, e.g. a protected branch) does not contain the bare `[rejected]` token and is excluded:\n * that is a real problem to surface, not a race to swallow.\n */\nexport function isNonFastForwardRejection(message: string): boolean {\n if (isStaleLeaseRejection(message)) return true;\n return /\\[rejected\\]/.test(message) && /fetch first|non-fast-forward/i.test(message);\n}\n\n/**\n * Whether a rejected plain push was a CONFIRMED race: the wording matches a non-fast-forward rejection\n * AND a re-fetch shows `branch` actually moved off `baseSha` — the tip the rejected push was based on.\n * The wording alone is not proof: the regexes are deliberately broad, so a PERSISTENT, unrelated push\n * failure (bad credentials, a flaky transport) could repeat the same wording forever; unconfirmed\n * answers 'not-a-race' and the caller fails loud. A failed re-fetch (`undefined` tip) is UNKNOWN, not\n * confirmation — never treat not knowing as proof of a race. The one `remoteMoved` expression also\n * covers a brand-new branch (`baseSha === undefined`): a defined tip already proves the branch now\n * exists on the remote. `refetchTip` is injectable so callers stay unit-testable without a real remote.\n */\nexport async function confirmPushRace(\n branch: string,\n baseSha: string | undefined,\n message: string,\n refetchTip: (branch: string) => Promise<string | undefined> = refetchBranchTip\n): Promise<'confirmed-race' | 'not-a-race'> {\n if (!isNonFastForwardRejection(message)) return 'not-a-race';\n const currentTip = await refetchTip(branch);\n const remoteMoved = currentTip !== undefined && currentTip !== baseSha;\n return remoteMoved ? 'confirmed-race' : 'not-a-race';\n}\n\n/**\n * Strip URL userinfo (`https://user:token@host` → `https://***@host`) from a git message before it\n * reaches a log or a summary: git prints the remote URL in push errors, and a remote may embed\n * credentials. Over-redaction is the safe direction — `ssh://git@host` loses nothing that matters.\n */\nexport function redactUrlCredentials(text: string): string {\n return text.replace(/\\/\\/[^\\s@/]+@/g, '//***@');\n}\n\n/**\n * Move the local `branch` back to `origin/<branch>`, dropping unpushed commits — the cleanup after a\n * lost push race, so the orphan commit cannot trip `checkoutPristine`'s guard on the clone's next run.\n * `reset --hard` writes the index, so a stale `index.lock` blocks it; the `update-ref` fallback does\n * not touch the index and still moves the ref off the orphan commit (the callers force-clean the tree\n * afterwards, in `restoreWorkspace`). Returns the failure message instead of throwing: the drop is\n * best-effort, and a failed drop must not escalate a confirmed-benign race.\n */\nexport async function dropLocalBranchToRemoteTip(branch: string): Promise<string | undefined> {\n try {\n await git.raw(['reset', '--hard', `origin/${branch}`]);\n return undefined;\n } catch (resetErr: any) {\n try {\n await git.raw(['update-ref', `refs/heads/${branch}`, `refs/remotes/origin/${branch}`]);\n return undefined;\n } catch {\n return String(resetErr?.message || resetErr);\n }\n }\n}\n\n/** Whether `origin` has the given branch. Assumes a `git fetch` isn't required (uses `ls-remote`). */\nexport async function branchExistsOnRemote(branch: string): Promise<boolean> {\n const out = await git.raw(['ls-remote', '--heads', 'origin', branch]);\n return out.trim().length > 0;\n}\n\n/**\n * Every branch `origin` has, by short name. `ls-remote` rather than `git branch -r` so the answer\n * cannot be narrowed by the checkout's refspec or staleness.\n */\nexport async function listRemoteBranches(): Promise<string[]> {\n const out = await git.raw(['ls-remote', '--heads', 'origin']);\n const prefix = 'refs/heads/';\n return out\n .split('\\n')\n .map((line) => line.split('\\t')[1]?.trim())\n .filter((ref): ref is string => Boolean(ref && ref.startsWith(prefix)))\n .map((ref) => ref.slice(prefix.length));\n}\n\n/**\n * Is `maybeAncestor` reachable from `descendant` (true for identical commits)? Not `merge-base\n * --is-ancestor`: it answers via the exit code, and simple-git's `raw` resolves on exit 1, so \"not an\n * ancestor\" would read as yes. Throws when the commits share no history or a revision cannot resolve.\n */\nexport async function isAncestor(maybeAncestor: string, descendant: string): Promise<boolean> {\n const ancestorSha = (await git.revparse([maybeAncestor])).trim();\n const mergeBase = (await git.raw(['merge-base', maybeAncestor, descendant])).trim();\n if (!ancestorSha || !mergeBase) throw new Error(`could not compare ${maybeAncestor} against ${descendant}`);\n return ancestorSha === mergeBase;\n}\n\n/** The prefix `git symbolic-ref refs/remotes/origin/HEAD` puts in front of the default branch name. */\nexport const ORIGIN_HEAD_REF_PREFIX = 'refs/remotes/origin/';\n\n/**\n * The default branch name out of `git symbolic-ref refs/remotes/origin/HEAD` output, or undefined for\n * an unrecognised shape. Strips the prefix; never splits on `/` — branch names may contain slashes\n * (`release/main`), and truncating would protect the wrong branch.\n */\nexport function parseOriginHeadRef(symbolicRefOutput: string): string | undefined {\n const ref = symbolicRefOutput.trim();\n if (!ref.startsWith(ORIGIN_HEAD_REF_PREFIX)) return undefined;\n return ref.slice(ORIGIN_HEAD_REF_PREFIX.length) || undefined;\n}\n\n/** The prefix a symref answer from `git ls-remote --symref origin HEAD` puts before the branch name. */\nconst LS_REMOTE_SYMREF_PREFIX = 'ref: refs/heads/';\n\n/**\n * The default branch name out of `git ls-remote --symref origin HEAD` output, or undefined when no\n * symref line is present (some servers omit it). Same slash discipline as {@link parseOriginHeadRef}.\n */\nexport function parseLsRemoteSymref(lsRemoteOutput: string): string | undefined {\n const line = lsRemoteOutput.split('\\n').find((l) => l.startsWith(LS_REMOTE_SYMREF_PREFIX));\n if (!line) return undefined;\n const name = line.slice(LS_REMOTE_SYMREF_PREFIX.length).split('\\t')[0].trim();\n return name || undefined;\n}\n\n/**\n * The remote's own answer for its default branch. Unlike the local `origin/HEAD` symref or enumerating\n * `origin/*`, this cannot be stale or narrowed — only unanswered (undefined hands on to the fallback).\n */\nexport async function remoteHeadBranch(run: GitArgsRunner = realGitRaw): Promise<string | undefined> {\n try {\n const out = await run(['ls-remote', '--symref', 'origin', 'HEAD']);\n return parseLsRemoteSymref(String(out ?? ''));\n } catch {\n return undefined;\n }\n}\n\n/**\n * The git repository's root, or undefined outside a repo. A bit workspace is not necessarily the repo\n * root, and GitHub only discovers workflows at `<repo>/.github/workflows`.\n */\nexport async function gitRepoRoot(): Promise<string | undefined> {\n try {\n const root = (await git.raw(['rev-parse', '--show-toplevel'])).trim();\n return root || undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reading `git config`, injectable so the identity decision can be unit tested without a repository.\n * There is deliberately no writer — see {@link resolveGitIdentity}.\n */\nexport type GitConfigIO = {\n /** the configured value, or undefined when unset (or when git cannot answer) */\n get(key: string): Promise<string | undefined>;\n};\n\nexport const realGitConfigIO: GitConfigIO = {\n get: (key) =>\n git\n .raw(['config', '--get', key])\n .then((out) => (out.trim().length ? out.trim() : undefined))\n // A missing key and \"not a git repository\" both exit non-zero; both mean \"no identity to keep\".\n .catch(() => undefined),\n};\n\n/**\n * The identity the sync commits with when nothing else says otherwise. A contract: the scaffolded\n * workflow templates (`init-scaffold.ts`) and the GitHub Action's defaults must carry the same pair,\n * or the same repository commits under different authors depending on entry point.\n */\nexport const DEFAULT_GIT_USER_NAME = 'bit-sync[bot]';\nexport const DEFAULT_GIT_USER_EMAIL = 'bit-sync[bot]@users.noreply.github.com';\n\nexport type GitIdentity = { name: string; email: string };\n\n/**\n * Who the sync commits as. Read-only on purpose: writing these keys into the repository's config\n * would outlive the run and re-author the developer's own later commits as the bot. Precedence per\n * key: configured git identity > `GIT_USER_NAME`/`GIT_USER_EMAIL` > default.\n */\nexport async function resolveGitIdentity(\n io: GitConfigIO = realGitConfigIO,\n env: NodeJS.ProcessEnv = process.env\n): Promise<GitIdentity> {\n return {\n name: (await io.get('user.name')) || env.GIT_USER_NAME || DEFAULT_GIT_USER_NAME,\n email: (await io.get('user.email')) || env.GIT_USER_EMAIL || DEFAULT_GIT_USER_EMAIL,\n };\n}\n\n/** The `git -c` pair that applies an identity to ONE invocation, leaving the repo's config alone. */\nexport function identityArgs(identity: GitIdentity): string[] {\n return ['-c', `user.name=${identity.name}`, '-c', `user.email=${identity.email}`];\n}\n\nexport type IdentityDeps = { run?: GitArgsRunner; io?: GitConfigIO; env?: NodeJS.ProcessEnv };\n\n/**\n * Run a git command that may author a commit. Every such command needs the identity — a fresh CI\n * checkout has none, and git refuses to commit (\"Please tell me who you are\") without one.\n */\nexport async function gitWithIdentity(args: string[], deps: IdentityDeps = {}): Promise<string> {\n const { run = realGitRaw, io = realGitConfigIO, env = process.env } = deps;\n const identity = await resolveGitIdentity(io, env);\n return String((await run([...identityArgs(identity), ...args])) ?? '');\n}\n\n/** `git commit` under the sync identity; `extraArgs` carries flags such as `--allow-empty`. */\nexport async function commitWithIdentity(\n message: string,\n opts: IdentityDeps & { extraArgs?: string[] } = {}\n): Promise<void> {\n const { extraArgs = [], ...deps } = opts;\n await gitWithIdentity(['commit', '-m', message, ...extraArgs], deps);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmD,MAAAI,SAAA;AAAA,SAAAC,yBAAAC,CAAA,EAAAC,CAAA,gBAAAD,CAAA,iBAAAE,CAAA,EAAAC,CAAA,EAAAC,CAAA,GAAAC,6BAAA,CAAAL,CAAA,EAAAC,CAAA,OAAAK,MAAA,CAAAC,qBAAA,QAAAC,CAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAP,CAAA,QAAAG,CAAA,MAAAA,CAAA,GAAAK,CAAA,CAAAC,MAAA,EAAAN,CAAA,IAAAD,CAAA,GAAAM,CAAA,CAAAL,CAAA,UAAAF,CAAA,CAAAS,OAAA,CAAAR,CAAA,QAAAS,oBAAA,CAAAC,IAAA,CAAAZ,CAAA,EAAAE,CAAA,MAAAE,CAAA,CAAAF,CAAA,IAAAF,CAAA,CAAAE,CAAA,aAAAE,CAAA;AAAA,SAAAC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AC,CAAC,MAAMb,GAAG,CAAC,CAAC,GAAGuF,YAAY,CAACC,QAAQ,CAAC,EAAE,GAAG5F,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AACxE;;AAEA;AACO,eAAe+F,kBAAkBA,CACtCzD,OAAe,EACf0D,IAA6C,GAAG,CAAC,CAAC,EACnC;EACf,MAAM;MAAEC,SAAS,GAAG;IAAY,CAAC,GAAGD,IAAI;IAAbF,IAAI,GAAAhH,wBAAA,CAAKkH,IAAI,EAAAnH,SAAA;EACxC,MAAMgH,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAEvD,OAAO,EAAE,GAAG2D,SAAS,CAAC,EAAEH,IAAI,CAAC;AACtE","ignoreList":[]}
@@ -215,6 +215,45 @@ describe('deleteBranchArgs', () => {
215
215
  (0, _chai().expect)((0, _gitOps().isStaleLeaseRejection)('remote: GH006: Protected branch update failed')).to.equal(false);
216
216
  });
217
217
  });
218
+ describe('isNonFastForwardRejection', () => {
219
+ // The GitHub-style client-side check, in the shape this code actually receives: simple-git appends
220
+ // `--porcelain` to every push, so the rejected ref arrives as a TAB-separated status line, not the
221
+ // human `! [rejected]` wording.
222
+ const CLIENT_SIDE_REJECTION = '!\tHEAD:refs/heads/feature\t[rejected] (fetch first)\n' + "error: failed to push some refs to '/remote'\n" + 'hint: Updates were rejected because the remote contains work that you do\n' + 'hint: not have locally.';
223
+
224
+ // The server-side ref-lock check: a plain push racing a concurrent ref update on the local/file
225
+ // transport surfaces the SAME wording as a lease refusal, with no lease involved (reproduced in
226
+ // ci-sync.e2e.ts's "a rejected sync-commit push" test).
227
+ const SERVER_SIDE_REJECTION = '!\tHEAD:refs/heads/import-race-lane\t[remote rejected] (failed to update ref)\n' + "remote: error: cannot lock ref 'refs/heads/import-race-lane': is at abc123 but expected def456\n" + "error: failed to push some refs to '/remote'";
228
+ it('recognizes the client-side non-fast-forward wording, porcelain and human', () => {
229
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)(CLIENT_SIDE_REJECTION)).to.equal(true);
230
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('!\tmain:refs/heads/main\t[rejected] (non-fast-forward)')).to.equal(true);
231
+ // the human layout (no --porcelain) still matches — the token test is layout-independent
232
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('! [rejected] main -> main (non-fast-forward)')).to.equal(true);
233
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('To /remote\n ! [rejected] HEAD -> feature (fetch first)')).to.equal(true);
234
+ });
235
+ it('recognizes the server-side ref-lock wording a plain push can also hit', () => {
236
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)(SERVER_SIDE_REJECTION)).to.equal(true);
237
+ // Same wording `isStaleLeaseRejection` matches — a plain push can legitimately race into it too.
238
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('! [rejected] (delete) -> my-lane (stale info)')).to.equal(true);
239
+ });
240
+ it('does not mistake a server-side hook decline for a race', () => {
241
+ // `[remote rejected]` alone (no ref-lock/fetch-first wording) — a protected-branch/hook decline,
242
+ // a real problem to surface, not a race to swallow.
243
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('! [remote rejected] main -> main (protected branch hook declined)')).to.equal(false);
244
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('!\tHEAD:refs/heads/main\t[remote rejected] (pre-receive hook declined)')).to.equal(false);
245
+ (0, _chai().expect)((0, _gitOps().isNonFastForwardRejection)('remote: GH006: Protected branch update failed')).to.equal(false);
246
+ });
247
+ });
248
+ describe('redactUrlCredentials', () => {
249
+ it('strips embedded credentials from a push-error remote URL', () => {
250
+ (0, _chai().expect)((0, _gitOps().redactUrlCredentials)("error: failed to push some refs to 'https://x-access-token:ghs_abc123@github.com/o/r'")).to.equal("error: failed to push some refs to 'https://***@github.com/o/r'");
251
+ });
252
+ it('leaves a credential-free message unchanged', () => {
253
+ const message = "error: failed to push some refs to 'https://github.com/o/r'\n ! [rejected] (fetch first)";
254
+ (0, _chai().expect)((0, _gitOps().redactUrlCredentials)(message)).to.equal(message);
255
+ });
256
+ });
218
257
  describe('isNonContentPath', () => {
219
258
  it('covers the two paths the executors never treat as workspace content, and nothing adjacent', () => {
220
259
  ['.bit', '.bit/objects/ab/cdef', 'node_modules/lodash/index.js'].forEach(p => (0, _chai().expect)((0, _gitOps().isNonContentPath)(p), p).to.equal(true));
@@ -1 +1 @@
1
- {"version":3,"names":["_chai","data","require","_gitOps","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","fakeConfig","initial","get","key","DEV","BOT_ENV","GIT_USER_NAME","GIT_USER_EMAIL","IDENTITY","name","userName","DEFAULT_GIT_USER_NAME","email","DEFAULT_GIT_USER_EMAIL","config","env","describe","it","expect","resolveGitIdentity","to","deep","equal","recorder","argv","run","args","deps","io","commitWithIdentity","some","includes","extraArgs","calls","fetchRemoteHeads","ALL_HEADS_REFSPEC","tip","refetchBranchTip","singleHeadRefspec","Error","undefined","SHA","deleteBranchArgs","isStaleLeaseRejection","p","isNonContentPath","failFastPath","arg","startsWith","addAllExceptScopeAndModules","fast","fallback","reset","find","SYNC_EXCLUDED_PATHS","path","include","slice","ORIGIN_HEAD","input","expected","parseOriginHeadRef","JSON","stringify","CLEAN","revParse","containedIn","steps","join","reload","checkoutPristine","message","catch","contain","step","SYMREF_OUT","parseLsRemoteSymref","remoteHeadBranch","assertCheckoutableBranch","throw","not","threw","localBranchExists","restoreRecorder","localBranchIsPresent","checkoutPristineRestore"],"sources":["git-ops.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport type { GitConfigIO } from './git-ops';\nimport {\n ALL_HEADS_REFSPEC,\n SYNC_EXCLUDED_PATHS,\n addAllExceptScopeAndModules,\n assertCheckoutableBranch,\n checkoutPristine,\n checkoutPristineRestore,\n commitWithIdentity,\n deleteBranchArgs,\n localBranchExists,\n DEFAULT_GIT_USER_EMAIL,\n DEFAULT_GIT_USER_NAME,\n fetchRemoteHeads,\n isNonContentPath,\n isStaleLeaseRejection,\n parseLsRemoteSymref,\n parseOriginHeadRef,\n refetchBranchTip,\n remoteHeadBranch,\n resolveGitIdentity,\n singleHeadRefspec,\n} from './git-ops';\n\n/** A read-only stand-in for `git config --get`. There is no setter: nothing may write the config. */\nfunction fakeConfig(initial: Record<string, string> = {}): GitConfigIO {\n return { get: async (key) => initial[key] };\n}\n\nconst DEV = { 'user.email': 'dev@example.com', 'user.name': 'A Developer' };\nconst BOT_ENV = { GIT_USER_NAME: 'Release Bot', GIT_USER_EMAIL: 'release@acme.example' };\n\n/**\n * Precedence: a configured identity outranks the environment (the var means \"when there is nobody\n * else\"), and an empty value counts as missing on both sides, because git treats it that way too.\n * `env` is always passed explicitly — otherwise a developer who exports GIT_USER_NAME fails the suite.\n */\nconst IDENTITY: Array<{\n name: string;\n config?: Record<string, string>;\n env?: Record<string, string>;\n userName: string;\n email: string;\n}> = [\n { name: 'a fresh CI checkout has neither half', userName: DEFAULT_GIT_USER_NAME, email: DEFAULT_GIT_USER_EMAIL },\n {\n name: 'only the email is configured',\n config: { 'user.email': 'dev@example.com' },\n userName: DEFAULT_GIT_USER_NAME,\n email: 'dev@example.com',\n },\n {\n name: 'only the name is configured',\n config: { 'user.name': 'A Developer' },\n userName: 'A Developer',\n email: DEFAULT_GIT_USER_EMAIL,\n },\n { name: 'both are already configured', config: DEV, userName: 'A Developer', email: 'dev@example.com' },\n {\n name: 'the configured values are empty, which git reads as missing',\n config: { 'user.email': '', 'user.name': '' },\n userName: DEFAULT_GIT_USER_NAME,\n email: DEFAULT_GIT_USER_EMAIL,\n },\n {\n name: 'the env vars supply an identity git has none of',\n env: BOT_ENV,\n userName: 'Release Bot',\n email: 'release@acme.example',\n },\n {\n name: 'the env vars are IGNORED because git already has an identity — a local run is never rewritten',\n config: DEV,\n env: BOT_ENV,\n userName: 'A Developer',\n email: 'dev@example.com',\n },\n {\n name: 'only one env var is set, so each key resolves independently',\n env: { GIT_USER_NAME: 'Release Bot' },\n userName: 'Release Bot',\n email: DEFAULT_GIT_USER_EMAIL,\n },\n {\n name: 'an env var is set to empty, which falls back as if unset',\n env: { GIT_USER_NAME: '', GIT_USER_EMAIL: '' },\n userName: DEFAULT_GIT_USER_NAME,\n email: DEFAULT_GIT_USER_EMAIL,\n },\n];\n\ndescribe('resolveGitIdentity', () => {\n IDENTITY.forEach(({ name, config, env, userName, email }) => {\n it(`resolves the identity when ${name}`, async () => {\n expect(await resolveGitIdentity(fakeConfig(config), env ?? {})).to.deep.equal({ name: userName, email });\n });\n });\n\n // Pinning the literals (not the constants) makes cross-repo drift show up as a failing test.\n it('defaults to the identity the scaffolded workflows and the action both document', () => {\n expect(DEFAULT_GIT_USER_NAME).to.equal('bit-sync[bot]');\n expect(DEFAULT_GIT_USER_EMAIL).to.equal('bit-sync[bot]@users.noreply.github.com');\n });\n});\n\n// The identity rides on the invocation. A `git config user.*` write would outlive the run and\n// re-author the developer's own later commits in that repository as the bot.\ndescribe('commitWithIdentity', () => {\n function recorder(config?: Record<string, string>, env: Record<string, string> = {}) {\n const argv: string[][] = [];\n const run = async (args: string[]) => {\n argv.push(args);\n return '';\n };\n return { argv, deps: { run, io: fakeConfig(config), env } };\n }\n\n it('carries the identity as -c on the commit itself, and writes no config at all', async () => {\n const { argv, deps } = recorder();\n await commitWithIdentity('chore(bit-sync): sync git to latest main scope versions', deps);\n expect(argv).to.deep.equal([\n [\n '-c',\n `user.name=${DEFAULT_GIT_USER_NAME}`,\n '-c',\n `user.email=${DEFAULT_GIT_USER_EMAIL}`,\n 'commit',\n '-m',\n 'chore(bit-sync): sync git to latest main scope versions',\n ],\n ]);\n // no `config`/`addConfig` call of any shape — and GitConfigIO has no setter to make one with\n expect(argv.some((args) => args.includes('config') || args.includes('addConfig'))).to.equal(false);\n });\n\n it('honours a configured identity and appends the extra flags after the message', async () => {\n const { argv, deps } = recorder(DEV, BOT_ENV);\n await commitWithIdentity('chore(bit-sync): sync lane', { ...deps, extraArgs: ['--allow-empty'] });\n expect(argv).to.deep.equal([\n [\n '-c',\n 'user.name=A Developer',\n '-c',\n 'user.email=dev@example.com',\n 'commit',\n '-m',\n 'chore(bit-sync): sync lane',\n '--allow-empty',\n ],\n ]);\n });\n});\n\ndescribe('fetchRemoteHeads', () => {\n it('passes the all-heads refspec explicitly, overriding whatever the checkout configured', async () => {\n const calls: string[][] = [];\n await fetchRemoteHeads(async (args) => {\n calls.push(args);\n });\n expect(calls).to.deep.equal([['fetch', 'origin', ALL_HEADS_REFSPEC]]);\n expect(ALL_HEADS_REFSPEC).to.equal('+refs/heads/*:refs/remotes/origin/*');\n });\n});\n\n// A branch deletion is the one irreversible thing the reconciler does, and every input to it was read\n// from refs fetched once per run — so the tip is re-read here, and leased on in the push itself.\ndescribe('refetchBranchTip', () => {\n it('re-fetches exactly that one head, then reads the remote-tracking ref it just wrote', async () => {\n const argv: string[][] = [];\n const tip = await refetchBranchTip('my-lane', async (args) => {\n argv.push(args);\n return args[0] === 'rev-parse' ? 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1\\n' : '';\n });\n expect(argv).to.deep.equal([\n ['fetch', 'origin', '+refs/heads/my-lane:refs/remotes/origin/my-lane'],\n ['rev-parse', 'refs/remotes/origin/my-lane'],\n ]);\n expect(tip).to.equal('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1');\n expect(singleHeadRefspec('my-lane')).to.equal('+refs/heads/my-lane:refs/remotes/origin/my-lane');\n });\n\n // A stale sha here would license deleting a commit that is no longer the tip; undefined keeps the branch.\n it('is undefined — never a stale sha — when the fetch fails, the ref is gone, or the output is empty', async () => {\n expect(\n await refetchBranchTip('my-lane', async (args) => {\n if (args[0] === 'fetch') throw new Error(\"couldn't find remote ref refs/heads/my-lane\");\n return 'staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaale';\n })\n ).to.equal(undefined);\n expect(await refetchBranchTip('my-lane', async () => '')).to.equal(undefined);\n expect(await refetchBranchTip('my-lane', async () => undefined)).to.equal(undefined);\n });\n});\n\ndescribe('deleteBranchArgs', () => {\n const SHA = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1';\n\n it('leases the delete on the expected sha, keeping the full delete refspec', () => {\n expect(deleteBranchArgs('my-lane', SHA)).to.deep.equal([\n 'origin',\n `--force-with-lease=refs/heads/my-lane:${SHA}`,\n ':refs/heads/my-lane',\n ]);\n });\n\n // A bare `--delete <branch>` or a short lease ref would let a branch name be read as an option.\n it('never passes the branch name as a bare argument', () => {\n expect(deleteBranchArgs('-hostile', SHA)).to.deep.equal([\n 'origin',\n `--force-with-lease=refs/heads/-hostile:${SHA}`,\n ':refs/heads/-hostile',\n ]);\n });\n\n // Every refusal wording must read as a race. The third one is why this row exists: the local/file\n // transport says \"incorrect old value provided\", and matching only the first two reported a refused\n // delete as a failed one — caught by CI, whose e2e remotes use that transport.\n it('recognizes every lease-refusal wording, and not an unrelated push failure', () => {\n expect(isStaleLeaseRejection('! [rejected] (delete) -> my-lane (stale info)')).to.equal(true);\n expect(\n isStaleLeaseRejection(`remote: error: cannot lock ref 'refs/heads/my-lane': is at ${SHA} but expected abc123`)\n ).to.equal(true);\n expect(\n isStaleLeaseRejection('!\\t:refs/heads/race-lane\\t[remote rejected] (incorrect old value provided)')\n ).to.equal(true);\n expect(isStaleLeaseRejection('remote: GH006: Protected branch update failed')).to.equal(false);\n });\n});\n\ndescribe('isNonContentPath', () => {\n it('covers the two paths the executors never treat as workspace content, and nothing adjacent', () => {\n ['.bit', '.bit/objects/ab/cdef', 'node_modules/lodash/index.js'].forEach((p) =>\n expect(isNonContentPath(p), p).to.equal(true)\n );\n ['.bitmap', 'node_modules_backup/x'].forEach((p) => expect(isNonContentPath(p), p).to.equal(false));\n });\n});\n\n// Both paths must end with the same index: everything staged except `.bit` / `node_modules`. The\n// fallback exists because `git add` refuses a pathspec naming an ignored path.\ndescribe('addAllExceptScopeAndModules', () => {\n /** Records argv; `failFastPath` models git refusing the `:(exclude)` form (both trees gitignored). */\n function recorder(failFastPath = false) {\n const argv: string[][] = [];\n const run = async (args: string[]) => {\n argv.push(args);\n if (failFastPath && args.some((arg) => arg.startsWith(':(exclude)'))) {\n throw new Error('The following paths are ignored by one of your .gitignore files:\\n.bit\\nnode_modules');\n }\n return undefined;\n };\n return { argv, run };\n }\n\n it('excludes both trees by pathspec in one command, so git never traverses them', async () => {\n const { argv, run } = recorder();\n await addAllExceptScopeAndModules(run);\n expect(argv).to.deep.equal([['add', '-A', '--', '.', ':(exclude).bit', ':(exclude)node_modules']]);\n });\n\n it('falls back to add-then-reset when git refuses the pathspecs', async () => {\n const { argv, run } = recorder(true);\n await addAllExceptScopeAndModules(run);\n expect(argv).to.deep.equal([\n ['add', '-A', '--', '.', ':(exclude).bit', ':(exclude)node_modules'],\n ['add', '-A', '--', '.'],\n ['reset', '-q', '--', '.bit', 'node_modules'],\n ]);\n });\n\n // Either shape must cover every excluded path, or a new entry silently stops being excluded.\n it('names every excluded path on both paths', async () => {\n const fast = recorder();\n await addAllExceptScopeAndModules(fast.run);\n const fallback = recorder(true);\n await addAllExceptScopeAndModules(fallback.run);\n const reset = fallback.argv.find((args) => args[0] === 'reset') as string[];\n SYNC_EXCLUDED_PATHS.forEach((path) => {\n expect(fast.argv[0], path).to.include(`:(exclude)${path}`);\n expect(reset, path).to.include(path);\n });\n expect(reset.slice(3)).to.deep.equal(SYNC_EXCLUDED_PATHS);\n });\n});\n\n// A wrong default-branch name does not fail loudly — it protects the wrong branch. A slashed name is a\n// NAME, not a path to shorten, and an unrecognised shape must yield undefined so the caller can fall back.\nconst ORIGIN_HEAD: Array<[string, string | undefined]> = [\n ['refs/remotes/origin/main\\n', 'main'],\n ['refs/remotes/origin/master', 'master'],\n ['refs/remotes/origin/release/main', 'release/main'],\n ['refs/remotes/origin/team/x/main\\n', 'team/x/main'],\n ['refs/remotes/origin/feature/a/b/c', 'feature/a/b/c'],\n ['refs/heads/main', undefined],\n ['fatal: ref refs/remotes/origin/HEAD is not a symbolic ref', undefined],\n ['', undefined],\n [' ', undefined],\n ['refs/remotes/origin/', undefined],\n];\n\ndescribe('parseOriginHeadRef', () => {\n it('reads the branch name whole, or nothing at all', () => {\n ORIGIN_HEAD.forEach(([input, expected]) =>\n expect(parseOriginHeadRef(input), JSON.stringify(input)).to.equal(expected)\n );\n });\n});\n\n// These rows assert the ORDER of the three steps: a clean after the reload would leave the workspace\n// holding a `.bitmap` view of a tree that no longer exists.\ndescribe('checkoutPristine', () => {\n const CLEAN = 'clean -fd -e .bit -e node_modules';\n\n /** Records git argv and the reload interleaved, so ordering between the two is assertable. */\n function recorder(revParse = 'abc123\\n', containedIn = ' origin/some-branch\\n') {\n const steps: string[] = [];\n const run = async (args: string[]) => {\n steps.push(args.join(' '));\n // model the REAL runner: a missing ref resolves with empty output rather than rejecting\n if (args[0] === 'rev-parse') return revParse;\n if (args[0] === 'branch') return containedIn;\n return undefined;\n };\n const reload = async () => {\n steps.push('<reload>');\n };\n return { steps, run, reload };\n }\n\n it('with a startPoint: proves the reset is safe, creates-or-resets the branch, cleans, reloads', async () => {\n const { steps, run, reload } = recorder();\n await checkoutPristine('bit-sync/main', 'origin/main', reload, run);\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/bit-sync/main',\n 'branch -r --contains refs/heads/bit-sync/main',\n 'checkout -f -B bit-sync/main origin/main',\n CLEAN,\n '<reload>',\n ]);\n });\n\n it('without a startPoint: plain forced switch to an existing branch, then cleans, then reloads', async () => {\n const { steps, run, reload } = recorder();\n await checkoutPristine('main', undefined, reload, run);\n expect(steps).to.deep.equal(['checkout -f main', CLEAN, '<reload>']);\n });\n\n // `checkout -B` moves an existing local ref; unpushed commits would be orphaned to the reflog.\n it('REFUSES to reset a local branch whose commits no remote contains, before touching the tree', async () => {\n const { steps, run, reload } = recorder('abc123\\n', '\\n');\n let message = '';\n await checkoutPristine('my-lane', 'origin/my-lane', reload, run).catch((e) => {\n message = e.message;\n });\n expect(message).to.contain('local branch \"my-lane\" has commits that no remote branch contains');\n expect(steps.some((step) => step.startsWith('checkout'))).to.equal(false);\n expect(steps.some((step) => step.startsWith('clean'))).to.equal(false);\n });\n\n // Remote containment admits both legitimate reset shapes; start-point ancestry wrongly refuses one.\n it('allows the reset when any remote branch contains the local tip — even a different one than the start point', async () => {\n const { steps, run, reload } = recorder('abc123\\n', ' origin/policy-lane\\n');\n await checkoutPristine('policy-lane', 'origin/main', reload, run);\n expect(steps.some((step) => step === 'checkout -f -B policy-lane origin/main')).to.equal(true);\n });\n\n it('skips the safety proof when the branch does not exist locally (every CI clone)', async () => {\n const { steps, run, reload } = recorder('');\n await checkoutPristine('my-lane', 'origin/my-lane', reload, run);\n expect(steps.filter((step) => step.startsWith('branch -r'))).to.deep.equal([]);\n expect(steps.some((step) => step === 'checkout -f -B my-lane origin/my-lane')).to.equal(true);\n });\n});\n\ndescribe('parseLsRemoteSymref / remoteHeadBranch', () => {\n const SYMREF_OUT = 'ref: refs/heads/main\\tHEAD\\n1234abcd\\tHEAD\\n';\n\n it('reads the branch out of the symref line, keeping a slashed name whole', () => {\n expect(parseLsRemoteSymref(SYMREF_OUT)).to.equal('main');\n // same slash discipline as parseOriginHeadRef: `release/main` is a NAME, not a path to shorten\n expect(parseLsRemoteSymref('ref: refs/heads/release/main\\tHEAD\\nabc\\tHEAD\\n')).to.equal('release/main');\n });\n\n it('returns undefined when the server omits the symref line (protocol v0), rather than guessing', () => {\n expect(parseLsRemoteSymref('1234abcd\\tHEAD\\n')).to.equal(undefined);\n expect(parseLsRemoteSymref('')).to.equal(undefined);\n });\n\n it('asks the remote, not the local refs — and swallows an offline failure into undefined', async () => {\n const argv: string[][] = [];\n expect(\n await remoteHeadBranch(async (args) => {\n argv.push(args);\n return SYMREF_OUT;\n })\n ).to.equal('main');\n expect(argv).to.deep.equal([['ls-remote', '--symref', 'origin', 'HEAD']]);\n expect(\n await remoteHeadBranch(async () => {\n throw new Error('could not read from remote repository');\n })\n ).to.equal(undefined);\n });\n});\n\n/**\n * The default branch is derived from the remote, not from validated config, so the primitive that\n * builds the checkout argv is the last line of defence against an option-like name.\n */\ndescribe('assertCheckoutableBranch', () => {\n it('refuses a name git would read as an option, or reject as a ref, before any argv is built', () => {\n ['-x', '--force', '', 'has space', 'a..b', 'refs/heads/main', 'ends.lock'].forEach((name) => {\n expect(() => assertCheckoutableBranch(name), name).to.throw(/cannot check out/);\n });\n });\n\n it('accepts ordinary names, slashed names included', () => {\n ['main', 'master', 'release/main', 'feature/a-b_c', 'trunk'].forEach((name) => {\n expect(() => assertCheckoutableBranch(name), name).to.not.throw();\n });\n });\n\n it('is enforced by checkoutPristine itself, so every caller inherits it', async () => {\n const steps: string[] = [];\n let threw = false;\n await checkoutPristine(\n '-x',\n undefined,\n async () => {},\n async (args) => {\n steps.push(args.join(' '));\n }\n ).catch(() => {\n threw = true;\n });\n expect(threw).to.equal(true);\n expect(steps).to.deep.equal([]);\n });\n});\n\ndescribe('localBranchExists', () => {\n // simple-git's `raw` can resolve with empty output on non-zero exits, so all three missing-branch\n // runner behaviors (empty resolve, undefined resolve, rejection) must be false.\n it('asks for the LOCAL ref quietly, and is true only when that ref prints a sha', async () => {\n const argv: string[][] = [];\n expect(\n await localBranchExists('main', async (args) => {\n argv.push(args);\n return 'abc123\\n';\n })\n ).to.equal(true);\n expect(argv).to.deep.equal([['rev-parse', '--verify', '--quiet', 'refs/heads/main']]);\n expect(await localBranchExists('main', async () => '')).to.equal(false);\n expect(await localBranchExists('main', async () => undefined)).to.equal(false);\n expect(\n await localBranchExists('main', async () => {\n throw new Error('exit 1');\n })\n ).to.equal(false);\n });\n});\n\n// Each shape is wrong in the other environment: `-B origin/<branch>` in a developer's repo resets\n// their default branch; a plain switch in a detached-HEAD CI checkout fails outright.\ndescribe('checkoutPristineRestore', () => {\n function restoreRecorder(localBranchIsPresent: boolean) {\n const steps: string[] = [];\n const run = async (args: string[]) => {\n steps.push(args.join(' '));\n // model the REAL runner: a missing ref resolves with empty output rather than rejecting\n if (args[0] === 'rev-parse') return localBranchIsPresent ? 'abc123\\n' : '';\n if (args[0] === 'branch') return ' origin/some-branch\\n';\n return undefined;\n };\n const reload = async () => {\n steps.push('<reload>');\n };\n return { steps, run, reload };\n }\n\n it('local branch present: plain forced switch — never a -B that would reset it to origin', async () => {\n const { steps, run, reload } = restoreRecorder(true);\n await checkoutPristineRestore('main', reload, run);\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/main',\n 'checkout -f main',\n 'clean -fd -e .bit -e node_modules',\n '<reload>',\n ]);\n });\n\n it('local branch absent (detached-HEAD CI): forks it from origin/<branch> instead of failing', async () => {\n const { steps, run, reload } = restoreRecorder(false);\n await checkoutPristineRestore('main', reload, run);\n // the second rev-parse is checkoutPristine's own reset guard re-proving what restore just learned —\n // redundant but harmless, and cheaper than giving the guard a bypass parameter\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/main',\n 'rev-parse --verify --quiet refs/heads/main',\n 'checkout -f -B main origin/main',\n 'clean -fd -e .bit -e node_modules',\n '<reload>',\n ]);\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAqBmB,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,C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AACiD,KAAK,CAAC,CAAC/C,EAAE,CAACC,IAAI,CAACC,KAAK,CAAC,CAC1B,4CAA4C,EAC5C,kBAAkB,EAClB,mCAAmC,EACnC,UAAU,CACX,CAAC;EACJ,CAAC,CAAC;EAEFL,EAAE,CAAC,0FAA0F,EAAE,YAAY;IACzG,MAAM;MAAEkD,KAAK;MAAE1C,GAAG;MAAE4C;IAAO,CAAC,GAAGc,eAAe,CAAC,KAAK,CAAC;IACrD,MAAM,IAAAE,iCAAuB,EAAC,MAAM,EAAEhB,MAAM,EAAE5C,GAAG,CAAC;IAClD;IACA;IACA,IAAAP,cAAM,EAACiD,KAAK,CAAC,CAAC/C,EAAE,CAACC,IAAI,CAACC,KAAK,CAAC,CAC1B,4CAA4C,EAC5C,4CAA4C,EAC5C,iCAAiC,EACjC,mCAAmC,EACnC,UAAU,CACX,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_chai","data","require","_gitOps","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","fakeConfig","initial","get","key","DEV","BOT_ENV","GIT_USER_NAME","GIT_USER_EMAIL","IDENTITY","name","userName","DEFAULT_GIT_USER_NAME","email","DEFAULT_GIT_USER_EMAIL","config","env","describe","it","expect","resolveGitIdentity","to","deep","equal","recorder","argv","run","args","deps","io","commitWithIdentity","some","includes","extraArgs","calls","fetchRemoteHeads","ALL_HEADS_REFSPEC","tip","refetchBranchTip","singleHeadRefspec","Error","undefined","SHA","deleteBranchArgs","isStaleLeaseRejection","CLIENT_SIDE_REJECTION","SERVER_SIDE_REJECTION","isNonFastForwardRejection","redactUrlCredentials","message","p","isNonContentPath","failFastPath","arg","startsWith","addAllExceptScopeAndModules","fast","fallback","reset","find","SYNC_EXCLUDED_PATHS","path","include","slice","ORIGIN_HEAD","input","expected","parseOriginHeadRef","JSON","stringify","CLEAN","revParse","containedIn","steps","join","reload","checkoutPristine","catch","contain","step","SYMREF_OUT","parseLsRemoteSymref","remoteHeadBranch","assertCheckoutableBranch","throw","not","threw","localBranchExists","restoreRecorder","localBranchIsPresent","checkoutPristineRestore"],"sources":["git-ops.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport type { GitConfigIO } from './git-ops';\nimport {\n ALL_HEADS_REFSPEC,\n SYNC_EXCLUDED_PATHS,\n addAllExceptScopeAndModules,\n assertCheckoutableBranch,\n checkoutPristine,\n checkoutPristineRestore,\n commitWithIdentity,\n deleteBranchArgs,\n localBranchExists,\n DEFAULT_GIT_USER_EMAIL,\n DEFAULT_GIT_USER_NAME,\n fetchRemoteHeads,\n isNonContentPath,\n isNonFastForwardRejection,\n isStaleLeaseRejection,\n redactUrlCredentials,\n parseLsRemoteSymref,\n parseOriginHeadRef,\n refetchBranchTip,\n remoteHeadBranch,\n resolveGitIdentity,\n singleHeadRefspec,\n} from './git-ops';\n\n/** A read-only stand-in for `git config --get`. There is no setter: nothing may write the config. */\nfunction fakeConfig(initial: Record<string, string> = {}): GitConfigIO {\n return { get: async (key) => initial[key] };\n}\n\nconst DEV = { 'user.email': 'dev@example.com', 'user.name': 'A Developer' };\nconst BOT_ENV = { GIT_USER_NAME: 'Release Bot', GIT_USER_EMAIL: 'release@acme.example' };\n\n/**\n * Precedence: a configured identity outranks the environment (the var means \"when there is nobody\n * else\"), and an empty value counts as missing on both sides, because git treats it that way too.\n * `env` is always passed explicitly — otherwise a developer who exports GIT_USER_NAME fails the suite.\n */\nconst IDENTITY: Array<{\n name: string;\n config?: Record<string, string>;\n env?: Record<string, string>;\n userName: string;\n email: string;\n}> = [\n { name: 'a fresh CI checkout has neither half', userName: DEFAULT_GIT_USER_NAME, email: DEFAULT_GIT_USER_EMAIL },\n {\n name: 'only the email is configured',\n config: { 'user.email': 'dev@example.com' },\n userName: DEFAULT_GIT_USER_NAME,\n email: 'dev@example.com',\n },\n {\n name: 'only the name is configured',\n config: { 'user.name': 'A Developer' },\n userName: 'A Developer',\n email: DEFAULT_GIT_USER_EMAIL,\n },\n { name: 'both are already configured', config: DEV, userName: 'A Developer', email: 'dev@example.com' },\n {\n name: 'the configured values are empty, which git reads as missing',\n config: { 'user.email': '', 'user.name': '' },\n userName: DEFAULT_GIT_USER_NAME,\n email: DEFAULT_GIT_USER_EMAIL,\n },\n {\n name: 'the env vars supply an identity git has none of',\n env: BOT_ENV,\n userName: 'Release Bot',\n email: 'release@acme.example',\n },\n {\n name: 'the env vars are IGNORED because git already has an identity — a local run is never rewritten',\n config: DEV,\n env: BOT_ENV,\n userName: 'A Developer',\n email: 'dev@example.com',\n },\n {\n name: 'only one env var is set, so each key resolves independently',\n env: { GIT_USER_NAME: 'Release Bot' },\n userName: 'Release Bot',\n email: DEFAULT_GIT_USER_EMAIL,\n },\n {\n name: 'an env var is set to empty, which falls back as if unset',\n env: { GIT_USER_NAME: '', GIT_USER_EMAIL: '' },\n userName: DEFAULT_GIT_USER_NAME,\n email: DEFAULT_GIT_USER_EMAIL,\n },\n];\n\ndescribe('resolveGitIdentity', () => {\n IDENTITY.forEach(({ name, config, env, userName, email }) => {\n it(`resolves the identity when ${name}`, async () => {\n expect(await resolveGitIdentity(fakeConfig(config), env ?? {})).to.deep.equal({ name: userName, email });\n });\n });\n\n // Pinning the literals (not the constants) makes cross-repo drift show up as a failing test.\n it('defaults to the identity the scaffolded workflows and the action both document', () => {\n expect(DEFAULT_GIT_USER_NAME).to.equal('bit-sync[bot]');\n expect(DEFAULT_GIT_USER_EMAIL).to.equal('bit-sync[bot]@users.noreply.github.com');\n });\n});\n\n// The identity rides on the invocation. A `git config user.*` write would outlive the run and\n// re-author the developer's own later commits in that repository as the bot.\ndescribe('commitWithIdentity', () => {\n function recorder(config?: Record<string, string>, env: Record<string, string> = {}) {\n const argv: string[][] = [];\n const run = async (args: string[]) => {\n argv.push(args);\n return '';\n };\n return { argv, deps: { run, io: fakeConfig(config), env } };\n }\n\n it('carries the identity as -c on the commit itself, and writes no config at all', async () => {\n const { argv, deps } = recorder();\n await commitWithIdentity('chore(bit-sync): sync git to latest main scope versions', deps);\n expect(argv).to.deep.equal([\n [\n '-c',\n `user.name=${DEFAULT_GIT_USER_NAME}`,\n '-c',\n `user.email=${DEFAULT_GIT_USER_EMAIL}`,\n 'commit',\n '-m',\n 'chore(bit-sync): sync git to latest main scope versions',\n ],\n ]);\n // no `config`/`addConfig` call of any shape — and GitConfigIO has no setter to make one with\n expect(argv.some((args) => args.includes('config') || args.includes('addConfig'))).to.equal(false);\n });\n\n it('honours a configured identity and appends the extra flags after the message', async () => {\n const { argv, deps } = recorder(DEV, BOT_ENV);\n await commitWithIdentity('chore(bit-sync): sync lane', { ...deps, extraArgs: ['--allow-empty'] });\n expect(argv).to.deep.equal([\n [\n '-c',\n 'user.name=A Developer',\n '-c',\n 'user.email=dev@example.com',\n 'commit',\n '-m',\n 'chore(bit-sync): sync lane',\n '--allow-empty',\n ],\n ]);\n });\n});\n\ndescribe('fetchRemoteHeads', () => {\n it('passes the all-heads refspec explicitly, overriding whatever the checkout configured', async () => {\n const calls: string[][] = [];\n await fetchRemoteHeads(async (args) => {\n calls.push(args);\n });\n expect(calls).to.deep.equal([['fetch', 'origin', ALL_HEADS_REFSPEC]]);\n expect(ALL_HEADS_REFSPEC).to.equal('+refs/heads/*:refs/remotes/origin/*');\n });\n});\n\n// A branch deletion is the one irreversible thing the reconciler does, and every input to it was read\n// from refs fetched once per run — so the tip is re-read here, and leased on in the push itself.\ndescribe('refetchBranchTip', () => {\n it('re-fetches exactly that one head, then reads the remote-tracking ref it just wrote', async () => {\n const argv: string[][] = [];\n const tip = await refetchBranchTip('my-lane', async (args) => {\n argv.push(args);\n return args[0] === 'rev-parse' ? 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1\\n' : '';\n });\n expect(argv).to.deep.equal([\n ['fetch', 'origin', '+refs/heads/my-lane:refs/remotes/origin/my-lane'],\n ['rev-parse', 'refs/remotes/origin/my-lane'],\n ]);\n expect(tip).to.equal('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1');\n expect(singleHeadRefspec('my-lane')).to.equal('+refs/heads/my-lane:refs/remotes/origin/my-lane');\n });\n\n // A stale sha here would license deleting a commit that is no longer the tip; undefined keeps the branch.\n it('is undefined — never a stale sha — when the fetch fails, the ref is gone, or the output is empty', async () => {\n expect(\n await refetchBranchTip('my-lane', async (args) => {\n if (args[0] === 'fetch') throw new Error(\"couldn't find remote ref refs/heads/my-lane\");\n return 'staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaale';\n })\n ).to.equal(undefined);\n expect(await refetchBranchTip('my-lane', async () => '')).to.equal(undefined);\n expect(await refetchBranchTip('my-lane', async () => undefined)).to.equal(undefined);\n });\n});\n\ndescribe('deleteBranchArgs', () => {\n const SHA = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1';\n\n it('leases the delete on the expected sha, keeping the full delete refspec', () => {\n expect(deleteBranchArgs('my-lane', SHA)).to.deep.equal([\n 'origin',\n `--force-with-lease=refs/heads/my-lane:${SHA}`,\n ':refs/heads/my-lane',\n ]);\n });\n\n // A bare `--delete <branch>` or a short lease ref would let a branch name be read as an option.\n it('never passes the branch name as a bare argument', () => {\n expect(deleteBranchArgs('-hostile', SHA)).to.deep.equal([\n 'origin',\n `--force-with-lease=refs/heads/-hostile:${SHA}`,\n ':refs/heads/-hostile',\n ]);\n });\n\n // Every refusal wording must read as a race. The third one is why this row exists: the local/file\n // transport says \"incorrect old value provided\", and matching only the first two reported a refused\n // delete as a failed one — caught by CI, whose e2e remotes use that transport.\n it('recognizes every lease-refusal wording, and not an unrelated push failure', () => {\n expect(isStaleLeaseRejection('! [rejected] (delete) -> my-lane (stale info)')).to.equal(true);\n expect(\n isStaleLeaseRejection(`remote: error: cannot lock ref 'refs/heads/my-lane': is at ${SHA} but expected abc123`)\n ).to.equal(true);\n expect(\n isStaleLeaseRejection('!\\t:refs/heads/race-lane\\t[remote rejected] (incorrect old value provided)')\n ).to.equal(true);\n expect(isStaleLeaseRejection('remote: GH006: Protected branch update failed')).to.equal(false);\n });\n});\n\ndescribe('isNonFastForwardRejection', () => {\n // The GitHub-style client-side check, in the shape this code actually receives: simple-git appends\n // `--porcelain` to every push, so the rejected ref arrives as a TAB-separated status line, not the\n // human `! [rejected]` wording.\n const CLIENT_SIDE_REJECTION =\n '!\\tHEAD:refs/heads/feature\\t[rejected] (fetch first)\\n' +\n \"error: failed to push some refs to '/remote'\\n\" +\n 'hint: Updates were rejected because the remote contains work that you do\\n' +\n 'hint: not have locally.';\n\n // The server-side ref-lock check: a plain push racing a concurrent ref update on the local/file\n // transport surfaces the SAME wording as a lease refusal, with no lease involved (reproduced in\n // ci-sync.e2e.ts's \"a rejected sync-commit push\" test).\n const SERVER_SIDE_REJECTION =\n '!\\tHEAD:refs/heads/import-race-lane\\t[remote rejected] (failed to update ref)\\n' +\n \"remote: error: cannot lock ref 'refs/heads/import-race-lane': is at abc123 but expected def456\\n\" +\n \"error: failed to push some refs to '/remote'\";\n\n it('recognizes the client-side non-fast-forward wording, porcelain and human', () => {\n expect(isNonFastForwardRejection(CLIENT_SIDE_REJECTION)).to.equal(true);\n expect(isNonFastForwardRejection('!\\tmain:refs/heads/main\\t[rejected] (non-fast-forward)')).to.equal(true);\n // the human layout (no --porcelain) still matches — the token test is layout-independent\n expect(isNonFastForwardRejection('! [rejected] main -> main (non-fast-forward)')).to.equal(true);\n expect(isNonFastForwardRejection('To /remote\\n ! [rejected] HEAD -> feature (fetch first)')).to.equal(true);\n });\n\n it('recognizes the server-side ref-lock wording a plain push can also hit', () => {\n expect(isNonFastForwardRejection(SERVER_SIDE_REJECTION)).to.equal(true);\n // Same wording `isStaleLeaseRejection` matches — a plain push can legitimately race into it too.\n expect(isNonFastForwardRejection('! [rejected] (delete) -> my-lane (stale info)')).to.equal(true);\n });\n\n it('does not mistake a server-side hook decline for a race', () => {\n // `[remote rejected]` alone (no ref-lock/fetch-first wording) — a protected-branch/hook decline,\n // a real problem to surface, not a race to swallow.\n expect(isNonFastForwardRejection('! [remote rejected] main -> main (protected branch hook declined)')).to.equal(\n false\n );\n expect(\n isNonFastForwardRejection('!\\tHEAD:refs/heads/main\\t[remote rejected] (pre-receive hook declined)')\n ).to.equal(false);\n expect(isNonFastForwardRejection('remote: GH006: Protected branch update failed')).to.equal(false);\n });\n});\n\ndescribe('redactUrlCredentials', () => {\n it('strips embedded credentials from a push-error remote URL', () => {\n expect(\n redactUrlCredentials(\"error: failed to push some refs to 'https://x-access-token:ghs_abc123@github.com/o/r'\")\n ).to.equal(\"error: failed to push some refs to 'https://***@github.com/o/r'\");\n });\n\n it('leaves a credential-free message unchanged', () => {\n const message = \"error: failed to push some refs to 'https://github.com/o/r'\\n ! [rejected] (fetch first)\";\n expect(redactUrlCredentials(message)).to.equal(message);\n });\n});\n\ndescribe('isNonContentPath', () => {\n it('covers the two paths the executors never treat as workspace content, and nothing adjacent', () => {\n ['.bit', '.bit/objects/ab/cdef', 'node_modules/lodash/index.js'].forEach((p) =>\n expect(isNonContentPath(p), p).to.equal(true)\n );\n ['.bitmap', 'node_modules_backup/x'].forEach((p) => expect(isNonContentPath(p), p).to.equal(false));\n });\n});\n\n// Both paths must end with the same index: everything staged except `.bit` / `node_modules`. The\n// fallback exists because `git add` refuses a pathspec naming an ignored path.\ndescribe('addAllExceptScopeAndModules', () => {\n /** Records argv; `failFastPath` models git refusing the `:(exclude)` form (both trees gitignored). */\n function recorder(failFastPath = false) {\n const argv: string[][] = [];\n const run = async (args: string[]) => {\n argv.push(args);\n if (failFastPath && args.some((arg) => arg.startsWith(':(exclude)'))) {\n throw new Error('The following paths are ignored by one of your .gitignore files:\\n.bit\\nnode_modules');\n }\n return undefined;\n };\n return { argv, run };\n }\n\n it('excludes both trees by pathspec in one command, so git never traverses them', async () => {\n const { argv, run } = recorder();\n await addAllExceptScopeAndModules(run);\n expect(argv).to.deep.equal([['add', '-A', '--', '.', ':(exclude).bit', ':(exclude)node_modules']]);\n });\n\n it('falls back to add-then-reset when git refuses the pathspecs', async () => {\n const { argv, run } = recorder(true);\n await addAllExceptScopeAndModules(run);\n expect(argv).to.deep.equal([\n ['add', '-A', '--', '.', ':(exclude).bit', ':(exclude)node_modules'],\n ['add', '-A', '--', '.'],\n ['reset', '-q', '--', '.bit', 'node_modules'],\n ]);\n });\n\n // Either shape must cover every excluded path, or a new entry silently stops being excluded.\n it('names every excluded path on both paths', async () => {\n const fast = recorder();\n await addAllExceptScopeAndModules(fast.run);\n const fallback = recorder(true);\n await addAllExceptScopeAndModules(fallback.run);\n const reset = fallback.argv.find((args) => args[0] === 'reset') as string[];\n SYNC_EXCLUDED_PATHS.forEach((path) => {\n expect(fast.argv[0], path).to.include(`:(exclude)${path}`);\n expect(reset, path).to.include(path);\n });\n expect(reset.slice(3)).to.deep.equal(SYNC_EXCLUDED_PATHS);\n });\n});\n\n// A wrong default-branch name does not fail loudly — it protects the wrong branch. A slashed name is a\n// NAME, not a path to shorten, and an unrecognised shape must yield undefined so the caller can fall back.\nconst ORIGIN_HEAD: Array<[string, string | undefined]> = [\n ['refs/remotes/origin/main\\n', 'main'],\n ['refs/remotes/origin/master', 'master'],\n ['refs/remotes/origin/release/main', 'release/main'],\n ['refs/remotes/origin/team/x/main\\n', 'team/x/main'],\n ['refs/remotes/origin/feature/a/b/c', 'feature/a/b/c'],\n ['refs/heads/main', undefined],\n ['fatal: ref refs/remotes/origin/HEAD is not a symbolic ref', undefined],\n ['', undefined],\n [' ', undefined],\n ['refs/remotes/origin/', undefined],\n];\n\ndescribe('parseOriginHeadRef', () => {\n it('reads the branch name whole, or nothing at all', () => {\n ORIGIN_HEAD.forEach(([input, expected]) =>\n expect(parseOriginHeadRef(input), JSON.stringify(input)).to.equal(expected)\n );\n });\n});\n\n// These rows assert the ORDER of the three steps: a clean after the reload would leave the workspace\n// holding a `.bitmap` view of a tree that no longer exists.\ndescribe('checkoutPristine', () => {\n const CLEAN = 'clean -fd -e .bit -e node_modules';\n\n /** Records git argv and the reload interleaved, so ordering between the two is assertable. */\n function recorder(revParse = 'abc123\\n', containedIn = ' origin/some-branch\\n') {\n const steps: string[] = [];\n const run = async (args: string[]) => {\n steps.push(args.join(' '));\n // model the REAL runner: a missing ref resolves with empty output rather than rejecting\n if (args[0] === 'rev-parse') return revParse;\n if (args[0] === 'branch') return containedIn;\n return undefined;\n };\n const reload = async () => {\n steps.push('<reload>');\n };\n return { steps, run, reload };\n }\n\n it('with a startPoint: proves the reset is safe, creates-or-resets the branch, cleans, reloads', async () => {\n const { steps, run, reload } = recorder();\n await checkoutPristine('bit-sync/main', 'origin/main', reload, run);\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/bit-sync/main',\n 'branch -r --contains refs/heads/bit-sync/main',\n 'checkout -f -B bit-sync/main origin/main',\n CLEAN,\n '<reload>',\n ]);\n });\n\n it('without a startPoint: plain forced switch to an existing branch, then cleans, then reloads', async () => {\n const { steps, run, reload } = recorder();\n await checkoutPristine('main', undefined, reload, run);\n expect(steps).to.deep.equal(['checkout -f main', CLEAN, '<reload>']);\n });\n\n // `checkout -B` moves an existing local ref; unpushed commits would be orphaned to the reflog.\n it('REFUSES to reset a local branch whose commits no remote contains, before touching the tree', async () => {\n const { steps, run, reload } = recorder('abc123\\n', '\\n');\n let message = '';\n await checkoutPristine('my-lane', 'origin/my-lane', reload, run).catch((e) => {\n message = e.message;\n });\n expect(message).to.contain('local branch \"my-lane\" has commits that no remote branch contains');\n expect(steps.some((step) => step.startsWith('checkout'))).to.equal(false);\n expect(steps.some((step) => step.startsWith('clean'))).to.equal(false);\n });\n\n // Remote containment admits both legitimate reset shapes; start-point ancestry wrongly refuses one.\n it('allows the reset when any remote branch contains the local tip — even a different one than the start point', async () => {\n const { steps, run, reload } = recorder('abc123\\n', ' origin/policy-lane\\n');\n await checkoutPristine('policy-lane', 'origin/main', reload, run);\n expect(steps.some((step) => step === 'checkout -f -B policy-lane origin/main')).to.equal(true);\n });\n\n it('skips the safety proof when the branch does not exist locally (every CI clone)', async () => {\n const { steps, run, reload } = recorder('');\n await checkoutPristine('my-lane', 'origin/my-lane', reload, run);\n expect(steps.filter((step) => step.startsWith('branch -r'))).to.deep.equal([]);\n expect(steps.some((step) => step === 'checkout -f -B my-lane origin/my-lane')).to.equal(true);\n });\n});\n\ndescribe('parseLsRemoteSymref / remoteHeadBranch', () => {\n const SYMREF_OUT = 'ref: refs/heads/main\\tHEAD\\n1234abcd\\tHEAD\\n';\n\n it('reads the branch out of the symref line, keeping a slashed name whole', () => {\n expect(parseLsRemoteSymref(SYMREF_OUT)).to.equal('main');\n // same slash discipline as parseOriginHeadRef: `release/main` is a NAME, not a path to shorten\n expect(parseLsRemoteSymref('ref: refs/heads/release/main\\tHEAD\\nabc\\tHEAD\\n')).to.equal('release/main');\n });\n\n it('returns undefined when the server omits the symref line (protocol v0), rather than guessing', () => {\n expect(parseLsRemoteSymref('1234abcd\\tHEAD\\n')).to.equal(undefined);\n expect(parseLsRemoteSymref('')).to.equal(undefined);\n });\n\n it('asks the remote, not the local refs — and swallows an offline failure into undefined', async () => {\n const argv: string[][] = [];\n expect(\n await remoteHeadBranch(async (args) => {\n argv.push(args);\n return SYMREF_OUT;\n })\n ).to.equal('main');\n expect(argv).to.deep.equal([['ls-remote', '--symref', 'origin', 'HEAD']]);\n expect(\n await remoteHeadBranch(async () => {\n throw new Error('could not read from remote repository');\n })\n ).to.equal(undefined);\n });\n});\n\n/**\n * The default branch is derived from the remote, not from validated config, so the primitive that\n * builds the checkout argv is the last line of defence against an option-like name.\n */\ndescribe('assertCheckoutableBranch', () => {\n it('refuses a name git would read as an option, or reject as a ref, before any argv is built', () => {\n ['-x', '--force', '', 'has space', 'a..b', 'refs/heads/main', 'ends.lock'].forEach((name) => {\n expect(() => assertCheckoutableBranch(name), name).to.throw(/cannot check out/);\n });\n });\n\n it('accepts ordinary names, slashed names included', () => {\n ['main', 'master', 'release/main', 'feature/a-b_c', 'trunk'].forEach((name) => {\n expect(() => assertCheckoutableBranch(name), name).to.not.throw();\n });\n });\n\n it('is enforced by checkoutPristine itself, so every caller inherits it', async () => {\n const steps: string[] = [];\n let threw = false;\n await checkoutPristine(\n '-x',\n undefined,\n async () => {},\n async (args) => {\n steps.push(args.join(' '));\n }\n ).catch(() => {\n threw = true;\n });\n expect(threw).to.equal(true);\n expect(steps).to.deep.equal([]);\n });\n});\n\ndescribe('localBranchExists', () => {\n // simple-git's `raw` can resolve with empty output on non-zero exits, so all three missing-branch\n // runner behaviors (empty resolve, undefined resolve, rejection) must be false.\n it('asks for the LOCAL ref quietly, and is true only when that ref prints a sha', async () => {\n const argv: string[][] = [];\n expect(\n await localBranchExists('main', async (args) => {\n argv.push(args);\n return 'abc123\\n';\n })\n ).to.equal(true);\n expect(argv).to.deep.equal([['rev-parse', '--verify', '--quiet', 'refs/heads/main']]);\n expect(await localBranchExists('main', async () => '')).to.equal(false);\n expect(await localBranchExists('main', async () => undefined)).to.equal(false);\n expect(\n await localBranchExists('main', async () => {\n throw new Error('exit 1');\n })\n ).to.equal(false);\n });\n});\n\n// Each shape is wrong in the other environment: `-B origin/<branch>` in a developer's repo resets\n// their default branch; a plain switch in a detached-HEAD CI checkout fails outright.\ndescribe('checkoutPristineRestore', () => {\n function restoreRecorder(localBranchIsPresent: boolean) {\n const steps: string[] = [];\n const run = async (args: string[]) => {\n steps.push(args.join(' '));\n // model the REAL runner: a missing ref resolves with empty output rather than rejecting\n if (args[0] === 'rev-parse') return localBranchIsPresent ? 'abc123\\n' : '';\n if (args[0] === 'branch') return ' origin/some-branch\\n';\n return undefined;\n };\n const reload = async () => {\n steps.push('<reload>');\n };\n return { steps, run, reload };\n }\n\n it('local branch present: plain forced switch — never a -B that would reset it to origin', async () => {\n const { steps, run, reload } = restoreRecorder(true);\n await checkoutPristineRestore('main', reload, run);\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/main',\n 'checkout -f main',\n 'clean -fd -e .bit -e node_modules',\n '<reload>',\n ]);\n });\n\n it('local branch absent (detached-HEAD CI): forks it from origin/<branch> instead of failing', async () => {\n const { steps, run, reload } = restoreRecorder(false);\n await checkoutPristineRestore('main', reload, run);\n // the second rev-parse is checkoutPristine's own reset guard re-proving what restore just learned —\n // redundant but harmless, and cheaper than giving the guard a bypass parameter\n expect(steps).to.deep.equal([\n 'rev-parse --verify --quiet refs/heads/main',\n 'rev-parse --verify --quiet refs/heads/main',\n 'checkout -f -B main origin/main',\n 'clean -fd -e .bit -e node_modules',\n '<reload>',\n ]);\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAuBmB,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAA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