@gitkraken/core-gitlens 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +72 -1
  2. package/dist/git/cache.d.ts +29 -5
  3. package/dist/git/cache.js +52 -11
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +6 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +28 -1
  8. package/dist/git/errors.js +45 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/features.d.ts +1 -1
  11. package/dist/git/features.js +1 -0
  12. package/dist/git/features.js.map +1 -1
  13. package/dist/git/models/reflog.d.ts +6 -0
  14. package/dist/git/models/reflog.js.map +1 -1
  15. package/dist/git/models/revision.d.ts +0 -1
  16. package/dist/git/models/revision.js +1 -2
  17. package/dist/git/models/revision.js.map +1 -1
  18. package/dist/git/providers/branches.d.ts +5 -1
  19. package/dist/git/providers/commits.d.ts +44 -2
  20. package/dist/git/providers/config.d.ts +7 -1
  21. package/dist/git/providers/operations.d.ts +19 -0
  22. package/dist/git/providers/provider.d.ts +29 -2
  23. package/dist/git/providers/refs.d.ts +48 -3
  24. package/dist/git/providers/revision.d.ts +7 -1
  25. package/dist/git/providers/staging.d.ts +13 -0
  26. package/dist/git/providers/stash.d.ts +3 -2
  27. package/dist/git/providers/status.d.ts +4 -0
  28. package/dist/git/providers/worktrees.d.ts +23 -3
  29. package/dist/git/run.types.d.ts +22 -0
  30. package/dist/git-cli/cliGitProvider.d.ts +39 -2
  31. package/dist/git-cli/cliGitProvider.js +109 -11
  32. package/dist/git-cli/cliGitProvider.js.map +1 -1
  33. package/dist/git-cli/exec/commandClassifier.d.ts +31 -0
  34. package/dist/git-cli/exec/commandClassifier.js +391 -0
  35. package/dist/git-cli/exec/commandClassifier.js.map +1 -0
  36. package/dist/git-cli/exec/git.d.ts +36 -5
  37. package/dist/git-cli/exec/git.js +163 -28
  38. package/dist/git-cli/exec/git.js.map +1 -1
  39. package/dist/git-cli/exec/gitQueue.d.ts +4 -1
  40. package/dist/git-cli/exec/gitQueue.js +1 -1
  41. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  42. package/dist/git-cli/parsers/reflogParser.d.ts +7 -0
  43. package/dist/git-cli/parsers/reflogParser.js +11 -1
  44. package/dist/git-cli/parsers/reflogParser.js.map +1 -1
  45. package/dist/git-cli/providers/branches.d.ts +10 -1
  46. package/dist/git-cli/providers/branches.js +31 -22
  47. package/dist/git-cli/providers/branches.js.map +1 -1
  48. package/dist/git-cli/providers/commits.d.ts +27 -3
  49. package/dist/git-cli/providers/commits.js +112 -12
  50. package/dist/git-cli/providers/commits.js.map +1 -1
  51. package/dist/git-cli/providers/config.js +2 -1
  52. package/dist/git-cli/providers/config.js.map +1 -1
  53. package/dist/git-cli/providers/diff.js +4 -4
  54. package/dist/git-cli/providers/diff.js.map +1 -1
  55. package/dist/git-cli/providers/operations.d.ts +13 -0
  56. package/dist/git-cli/providers/operations.js +64 -5
  57. package/dist/git-cli/providers/operations.js.map +1 -1
  58. package/dist/git-cli/providers/patch.js +21 -45
  59. package/dist/git-cli/providers/patch.js.map +1 -1
  60. package/dist/git-cli/providers/refs.d.ts +20 -3
  61. package/dist/git-cli/providers/refs.js +140 -10
  62. package/dist/git-cli/providers/refs.js.map +1 -1
  63. package/dist/git-cli/providers/remotes.js +3 -2
  64. package/dist/git-cli/providers/remotes.js.map +1 -1
  65. package/dist/git-cli/providers/revision.d.ts +5 -1
  66. package/dist/git-cli/providers/revision.js +20 -5
  67. package/dist/git-cli/providers/revision.js.map +1 -1
  68. package/dist/git-cli/providers/staging.d.ts +9 -0
  69. package/dist/git-cli/providers/staging.js +63 -6
  70. package/dist/git-cli/providers/staging.js.map +1 -1
  71. package/dist/git-cli/providers/stash.d.ts +3 -2
  72. package/dist/git-cli/providers/stash.js +34 -22
  73. package/dist/git-cli/providers/stash.js.map +1 -1
  74. package/dist/git-cli/providers/status.d.ts +2 -0
  75. package/dist/git-cli/providers/status.js +27 -9
  76. package/dist/git-cli/providers/status.js.map +1 -1
  77. package/dist/git-cli/providers/worktrees.d.ts +31 -2
  78. package/dist/git-cli/providers/worktrees.js +75 -7
  79. package/dist/git-cli/providers/worktrees.js.map +1 -1
  80. package/dist/plus/git-github/api/github.d.ts +64 -3
  81. package/dist/plus/git-github/api/github.js +237 -24
  82. package/dist/plus/git-github/api/github.js.map +1 -1
  83. package/dist/plus/git-github/providers/github/branches.d.ts +3 -1
  84. package/dist/plus/git-github/providers/github/branches.js +2 -1
  85. package/dist/plus/git-github/providers/github/branches.js.map +1 -1
  86. package/dist/plus/git-github/providers/github/commits.d.ts +4 -2
  87. package/dist/plus/git-github/providers/github/commits.js +3 -1
  88. package/dist/plus/git-github/providers/github/commits.js.map +1 -1
  89. package/dist/plus/git-github/providers/github/refs.d.ts +10 -3
  90. package/dist/plus/git-github/providers/github/refs.js +4 -4
  91. package/dist/plus/git-github/providers/github/refs.js.map +1 -1
  92. package/dist/plus/git-github/providers/github/revision.d.ts +4 -1
  93. package/dist/plus/git-github/providers/github/revision.js +6 -1
  94. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  95. package/dist/plus/integrations/index.d.ts +5 -2
  96. package/dist/plus/integrations/index.js.map +1 -1
  97. package/dist/plus/integrations/integrationService.d.ts +35 -9
  98. package/dist/plus/integrations/integrationService.js +16 -3
  99. package/dist/plus/integrations/integrationService.js.map +1 -1
  100. package/dist/plus/integrations/manager.d.ts +107 -37
  101. package/dist/plus/integrations/models/gitHostIntegration.d.ts +128 -13
  102. package/dist/plus/integrations/models/gitHostIntegration.js +130 -17
  103. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  104. package/dist/plus/integrations/models/integration.d.ts +51 -3
  105. package/dist/plus/integrations/models/integration.js +125 -18
  106. package/dist/plus/integrations/models/integration.js.map +1 -1
  107. package/dist/plus/integrations/models/issuesIntegration.d.ts +18 -5
  108. package/dist/plus/integrations/models/issuesIntegration.js +40 -10
  109. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  110. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  111. package/dist/plus/integrations/providers/azure/azure.js +13 -17
  112. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  113. package/dist/plus/integrations/providers/azure/models.d.ts +29 -0
  114. package/dist/plus/integrations/providers/azure/models.js +112 -1
  115. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  116. package/dist/plus/integrations/providers/azureDevOps.d.ts +54 -2
  117. package/dist/plus/integrations/providers/azureDevOps.js +80 -2
  118. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  119. package/dist/plus/integrations/providers/azureDevOpsServer.js +2 -1
  120. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  121. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +61 -0
  122. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +165 -23
  123. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  124. package/dist/plus/integrations/providers/bitbucket/models.d.ts +6 -1
  125. package/dist/plus/integrations/providers/bitbucket/models.js +4 -3
  126. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  127. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js +1 -1
  128. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js.map +1 -1
  129. package/dist/plus/integrations/providers/bitbucket-server.d.ts +38 -1
  130. package/dist/plus/integrations/providers/bitbucket-server.js +33 -1
  131. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  132. package/dist/plus/integrations/providers/bitbucket.d.ts +36 -1
  133. package/dist/plus/integrations/providers/bitbucket.js +29 -1
  134. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  135. package/dist/plus/integrations/providers/github.d.ts +48 -4
  136. package/dist/plus/integrations/providers/github.js +101 -6
  137. package/dist/plus/integrations/providers/github.js.map +1 -1
  138. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +35 -0
  139. package/dist/plus/integrations/providers/gitlab/gitlab.js +132 -15
  140. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  141. package/dist/plus/integrations/providers/gitlab/models.d.ts +1 -0
  142. package/dist/plus/integrations/providers/gitlab/models.js +1 -1
  143. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  144. package/dist/plus/integrations/providers/gitlab.d.ts +48 -1
  145. package/dist/plus/integrations/providers/gitlab.js +79 -3
  146. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  147. package/dist/plus/integrations/providers/jira-server.d.ts +3 -3
  148. package/dist/plus/integrations/providers/jira-server.js +3 -3
  149. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  150. package/dist/plus/integrations/providers/models.d.ts +12 -1
  151. package/dist/plus/integrations/providers/models.js +11 -1
  152. package/dist/plus/integrations/providers/models.js.map +1 -1
  153. package/dist/plus/integrations/providers/providerErrors.d.ts +9 -1
  154. package/dist/plus/integrations/providers/providerErrors.js +10 -1
  155. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  156. package/dist/plus/integrations/providers/providersApi.d.ts +59 -0
  157. package/dist/plus/integrations/providers/providersApi.js +136 -1
  158. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  159. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +42 -0
  160. package/dist/plus/integrations/providers/utils/providerPaging.js +58 -1
  161. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  162. package/dist/plus/integrations/providers/utils.d.ts +1 -1
  163. package/dist/plus/integrations/reads/currentAccount.d.ts +35 -0
  164. package/dist/plus/integrations/reads/currentAccount.js +46 -0
  165. package/dist/plus/integrations/reads/currentAccount.js.map +1 -0
  166. package/dist/plus/integrations/reads/drains.d.ts +4 -1
  167. package/dist/plus/integrations/reads/drains.js +7 -3
  168. package/dist/plus/integrations/reads/drains.js.map +1 -1
  169. package/dist/plus/integrations/reads/issueBatch.d.ts +72 -12
  170. package/dist/plus/integrations/reads/issueBatch.js +193 -48
  171. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  172. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +57 -0
  173. package/dist/plus/integrations/reads/pullRequestBatch.js +80 -0
  174. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -0
  175. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +58 -0
  176. package/dist/plus/integrations/reads/pullRequestBranches.js +111 -0
  177. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -0
  178. package/dist/plus/integrations/reads/pullRequests.js +3 -3
  179. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  180. package/dist/plus/integrations/reads/sweeps.js +3 -3
  181. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  182. package/dist/plus/integrations/results.d.ts +5 -2
  183. package/dist/plus/integrations/results.js.map +1 -1
  184. package/dist/utils/env/node/exec.js +1 -1
  185. package/dist/utils/env/node/exec.js.map +1 -1
  186. package/docs/integrations.md +90 -36
  187. package/docs/kepler-git-write-api-parity.md +365 -0
  188. package/docs/kepler-read-api-parity.md +75 -28
  189. package/package.json +1 -1
  190. package/dist/plus/integrations/reads/trackerIssue.d.ts +0 -33
  191. package/dist/plus/integrations/reads/trackerIssue.js +0 -60
  192. package/dist/plus/integrations/reads/trackerIssue.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reflogParser.js","names":[],"sources":["../../../../git-cli/src/parsers/reflogParser.ts"],"sourcesContent":["import type { GitReflog } from '@gitlens/git/models/reflog.js';\nimport { GitReflogRecord } from '@gitlens/git/models/reflog.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { LogParser } from './logParser.js';\nimport { createLogParser } from './logParser.js';\n\n// Layer 1 — Raw parser: extracts fields using binary separators via createLogParser\n\nconst reflogMapping = {\n\tsha: '%H',\n\tselector: '%gD',\n\tsubject: '%gs',\n};\n\ntype ReflogLogParser = LogParser<typeof reflogMapping>;\nlet _reflogParser: ReflogLogParser | undefined;\n\nexport function getReflogParser(): ReflogLogParser {\n\t_reflogParser ??= createLogParser(reflogMapping);\n\treturn _reflogParser;\n}\n\n// Layer 2 — Smart parser: correlates raw entries into GitReflogRecords\n\nfunction isHEADSelector(selector: string): boolean {\n\treturn selector === 'HEAD' || selector.endsWith('/HEAD');\n}\n\nexport function parseGitRefLog(\n\tparser: ReflogLogParser,\n\tdata: string,\n\trepoPath: string,\n\tcommands: string[],\n\tlimit: number,\n\ttotalLimit: number,\n): GitReflog | undefined {\n\tusing sw = maybeStopWatch(`Git.parseRefLog(${repoPath})`, { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst records: GitReflogRecord[] = [];\n\n\tlet sha: string;\n\tlet selector: string;\n\tlet date: string;\n\tlet command: string;\n\tlet commandArgs: string | undefined;\n\tlet details: string | undefined;\n\n\tlet head: string | undefined;\n\tlet headDate: string | undefined;\n\tlet headSha: string | undefined;\n\n\tlet count = 0;\n\tlet total = 0;\n\tlet recordDate: string | undefined;\n\tlet record: GitReflogRecord | undefined;\n\n\tlet idx: number;\n\n\tfor (const entry of parser.parse(data)) {\n\t\t// Parse selector: \"refs/heads/main@{date}\" → selector + date\n\t\tidx = entry.selector.indexOf('@{');\n\t\tif (idx === -1) continue;\n\n\t\tselector = entry.selector.substring(0, idx);\n\t\tdate = entry.selector.substring(idx + 2, entry.selector.length - 1);\n\t\tsha = entry.sha;\n\n\t\t// Extract command early (everything before the first space or colon)\n\t\t// to allow skipping the full subject parse for filtered-out entries\n\t\tconst subject = entry.subject;\n\t\tconst spaceIdx = subject.indexOf(' ');\n\t\tconst colonIdx = subject.indexOf(':');\n\n\t\tif (spaceIdx === -1 && colonIdx === -1) {\n\t\t\tcommand = subject;\n\t\t} else if (colonIdx !== -1 && (spaceIdx === -1 || colonIdx < spaceIdx)) {\n\t\t\tcommand = subject.substring(0, colonIdx);\n\t\t} else {\n\t\t\tcommand = subject.substring(0, spaceIdx);\n\t\t}\n\n\t\ttotal++;\n\n\t\tif (record !== undefined) {\n\t\t\t// If the next record has the same sha as the previous, use it if it is not pointing to just HEAD and the previous is\n\t\t\tif (\n\t\t\t\tsha === record.sha &&\n\t\t\t\t(date !== recordDate || !isHEADSelector(record.selector) || isHEADSelector(selector))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (sha !== record.sha) {\n\t\t\t\tif (\n\t\t\t\t\thead != null &&\n\t\t\t\t\theadDate === recordDate &&\n\t\t\t\t\theadSha === record.sha &&\n\t\t\t\t\tisHEADSelector(record.selector)\n\t\t\t\t) {\n\t\t\t\t\trecord.update(sha, head);\n\t\t\t\t} else {\n\t\t\t\t\trecord.update(sha);\n\t\t\t\t}\n\n\t\t\t\trecords.push(record);\n\t\t\t\trecord = undefined;\n\t\t\t\trecordDate = undefined;\n\n\t\t\t\tcount++;\n\t\t\t\tif (limit !== 0 && count >= limit) break;\n\t\t\t}\n\t\t}\n\n\t\tif (command === 'HEAD') {\n\t\t\thead = selector;\n\t\t\theadDate = date;\n\t\t\theadSha = sha;\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (commands.includes(command)) {\n\t\t\t// Only parse args/details when we're actually creating a record\n\t\t\tif (colonIdx === -1) {\n\t\t\t\tcommandArgs = spaceIdx !== -1 ? subject.substring(spaceIdx + 1) : undefined;\n\t\t\t\tdetails = undefined;\n\t\t\t} else {\n\t\t\t\tconst commandAndArgs = subject.substring(0, colonIdx);\n\t\t\t\tidx = commandAndArgs.indexOf(' ');\n\t\t\t\tcommandArgs = idx !== -1 ? commandAndArgs.substring(idx + 1) : undefined;\n\t\t\t\tdetails = colonIdx < subject.length - 1 ? subject.substring(colonIdx + 1).trimStart() : undefined;\n\t\t\t}\n\n\t\t\trecord = new GitReflogRecord(repoPath, sha, selector, new Date(date), command, commandArgs, details);\n\t\t\trecordDate = date;\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${records.length} records` });\n\n\treturn {\n\t\trepoPath: repoPath,\n\t\trecords: records,\n\t\tcount: count,\n\t\ttotal: total,\n\t\tlimit: limit,\n\t\thasMore: (limit !== 0 && count >= limit) || (totalLimit !== 0 && total >= totalLimit),\n\t};\n}\n"],"mappings":";;;;;AAQA,MAAM,gBAAgB;CACrB,KAAK;CACL,UAAU;CACV,SAAS;AACV;AAGA,IAAI;AAEJ,SAAgB,kBAAmC;CAClD,kBAAkB,gBAAgB,aAAa;CAC/C,OAAO;AACR;AAIA,SAAS,eAAe,UAA2B;CAClD,OAAO,aAAa,UAAU,SAAS,SAAS,OAAO;AACxD;AAEA,SAAgB,eACf,QACA,MACA,UACA,UACA,OACA,YACwB;;;EACxB,MAAM,KAAA,YAAA,EAAK,eAAe,mBAAmB,SAAS,IAAI,EAAE,KAAK;GAAE,UAAU;GAAM,OAAO;EAAQ,EAAE,CAAC,CAAA;EACrG,IAAI,CAAC,MAAM;GACV,IAAI,KAAK,EAAE,QAAQ,WAAW,CAAC;GAC/B;EACD;EAEA,MAAM,UAA6B,CAAC;EAEpC,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EAEJ,IAAI;EACJ,IAAI;EACJ,IAAI;EAEJ,IAAI,QAAQ;EACZ,IAAI,QAAQ;EACZ,IAAI;EACJ,IAAI;EAEJ,IAAI;EAEJ,KAAK,MAAM,SAAS,OAAO,MAAM,IAAI,GAAG;GAEvC,MAAM,MAAM,SAAS,QAAQ,IAAI;GACjC,IAAI,QAAQ,IAAI;GAEhB,WAAW,MAAM,SAAS,UAAU,GAAG,GAAG;GAC1C,OAAO,MAAM,SAAS,UAAU,MAAM,GAAG,MAAM,SAAS,SAAS,CAAC;GAClE,MAAM,MAAM;GAIZ,MAAM,UAAU,MAAM;GACtB,MAAM,WAAW,QAAQ,QAAQ,GAAG;GACpC,MAAM,WAAW,QAAQ,QAAQ,GAAG;GAE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ACP,SAAU,UAAU,KAAK,SAAS,SAAW,eAAe,KAAK,SAAS;EAC3E;;;;;;AACD"}
1
+ {"version":3,"file":"reflogParser.js","names":[],"sources":["../../../../git-cli/src/parsers/reflogParser.ts"],"sourcesContent":["import type { GitReflog } from '@gitlens/git/models/reflog.js';\nimport { GitReflogRecord } from '@gitlens/git/models/reflog.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { LogParser } from './logParser.js';\nimport { createLogParser } from './logParser.js';\n\n// Layer 1 — Raw parser: extracts fields using binary separators via createLogParser\n\nconst reflogMapping = {\n\tsha: '%H',\n\tselector: '%gD',\n\tsubject: '%gs',\n};\n\ntype ReflogLogParser = LogParser<typeof reflogMapping>;\nlet _reflogParser: ReflogLogParser | undefined;\n\nexport function getReflogParser(): ReflogLogParser {\n\t_reflogParser ??= createLogParser(reflogMapping);\n\treturn _reflogParser;\n}\n\nconst reflogEntryMapping = {\n\tsha: '%H',\n\tsubject: '%gs',\n};\n\ntype ReflogEntryLogParser = LogParser<typeof reflogEntryMapping>;\nlet _reflogEntryParser: ReflogEntryLogParser | undefined;\n\n/** Just a reflog entry's sha and message, for a read that never needs the selector */\nexport function getReflogEntryParser(): ReflogEntryLogParser {\n\t_reflogEntryParser ??= createLogParser(reflogEntryMapping);\n\treturn _reflogEntryParser;\n}\n\n// Layer 2 — Smart parser: correlates raw entries into GitReflogRecords\n\nfunction isHEADSelector(selector: string): boolean {\n\treturn selector === 'HEAD' || selector.endsWith('/HEAD');\n}\n\nexport function parseGitRefLog(\n\tparser: ReflogLogParser,\n\tdata: string,\n\trepoPath: string,\n\tcommands: string[],\n\tlimit: number,\n\ttotalLimit: number,\n): GitReflog | undefined {\n\tusing sw = maybeStopWatch(`Git.parseRefLog(${repoPath})`, { log: { onlyExit: true, level: 'debug' } });\n\tif (!data) {\n\t\tsw?.stop({ suffix: ` no data` });\n\t\treturn undefined;\n\t}\n\n\tconst records: GitReflogRecord[] = [];\n\n\tlet sha: string;\n\tlet selector: string;\n\tlet date: string;\n\tlet command: string;\n\tlet commandArgs: string | undefined;\n\tlet details: string | undefined;\n\n\tlet head: string | undefined;\n\tlet headDate: string | undefined;\n\tlet headSha: string | undefined;\n\n\tlet count = 0;\n\tlet total = 0;\n\tlet recordDate: string | undefined;\n\tlet record: GitReflogRecord | undefined;\n\n\tlet idx: number;\n\n\tfor (const entry of parser.parse(data)) {\n\t\t// Parse selector: \"refs/heads/main@{date}\" → selector + date\n\t\tidx = entry.selector.indexOf('@{');\n\t\tif (idx === -1) continue;\n\n\t\tselector = entry.selector.substring(0, idx);\n\t\tdate = entry.selector.substring(idx + 2, entry.selector.length - 1);\n\t\tsha = entry.sha;\n\n\t\t// Extract command early (everything before the first space or colon)\n\t\t// to allow skipping the full subject parse for filtered-out entries\n\t\tconst subject = entry.subject;\n\t\tconst spaceIdx = subject.indexOf(' ');\n\t\tconst colonIdx = subject.indexOf(':');\n\n\t\tif (spaceIdx === -1 && colonIdx === -1) {\n\t\t\tcommand = subject;\n\t\t} else if (colonIdx !== -1 && (spaceIdx === -1 || colonIdx < spaceIdx)) {\n\t\t\tcommand = subject.substring(0, colonIdx);\n\t\t} else {\n\t\t\tcommand = subject.substring(0, spaceIdx);\n\t\t}\n\n\t\ttotal++;\n\n\t\tif (record !== undefined) {\n\t\t\t// If the next record has the same sha as the previous, use it if it is not pointing to just HEAD and the previous is\n\t\t\tif (\n\t\t\t\tsha === record.sha &&\n\t\t\t\t(date !== recordDate || !isHEADSelector(record.selector) || isHEADSelector(selector))\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (sha !== record.sha) {\n\t\t\t\tif (\n\t\t\t\t\thead != null &&\n\t\t\t\t\theadDate === recordDate &&\n\t\t\t\t\theadSha === record.sha &&\n\t\t\t\t\tisHEADSelector(record.selector)\n\t\t\t\t) {\n\t\t\t\t\trecord.update(sha, head);\n\t\t\t\t} else {\n\t\t\t\t\trecord.update(sha);\n\t\t\t\t}\n\n\t\t\t\trecords.push(record);\n\t\t\t\trecord = undefined;\n\t\t\t\trecordDate = undefined;\n\n\t\t\t\tcount++;\n\t\t\t\tif (limit !== 0 && count >= limit) break;\n\t\t\t}\n\t\t}\n\n\t\tif (command === 'HEAD') {\n\t\t\thead = selector;\n\t\t\theadDate = date;\n\t\t\theadSha = sha;\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (commands.includes(command)) {\n\t\t\t// Only parse args/details when we're actually creating a record\n\t\t\tif (colonIdx === -1) {\n\t\t\t\tcommandArgs = spaceIdx !== -1 ? subject.substring(spaceIdx + 1) : undefined;\n\t\t\t\tdetails = undefined;\n\t\t\t} else {\n\t\t\t\tconst commandAndArgs = subject.substring(0, colonIdx);\n\t\t\t\tidx = commandAndArgs.indexOf(' ');\n\t\t\t\tcommandArgs = idx !== -1 ? commandAndArgs.substring(idx + 1) : undefined;\n\t\t\t\tdetails = colonIdx < subject.length - 1 ? subject.substring(colonIdx + 1).trimStart() : undefined;\n\t\t\t}\n\n\t\t\trecord = new GitReflogRecord(repoPath, sha, selector, new Date(date), command, commandArgs, details);\n\t\t\trecordDate = date;\n\t\t}\n\t}\n\n\tsw?.stop({ suffix: ` parsed ${records.length} records` });\n\n\treturn {\n\t\trepoPath: repoPath,\n\t\trecords: records,\n\t\tcount: count,\n\t\ttotal: total,\n\t\tlimit: limit,\n\t\thasMore: (limit !== 0 && count >= limit) || (totalLimit !== 0 && total >= totalLimit),\n\t};\n}\n"],"mappings":";;;;;AAQA,MAAM,gBAAgB;CACrB,KAAK;CACL,UAAU;CACV,SAAS;AACV;AAGA,IAAI;AAEJ,SAAgB,kBAAmC;CAClD,kBAAkB,gBAAgB,aAAa;CAC/C,OAAO;AACR;AAEA,MAAM,qBAAqB;CAC1B,KAAK;CACL,SAAS;AACV;AAGA,IAAI;;AAGJ,SAAgB,uBAA6C;CAC5D,uBAAuB,gBAAgB,kBAAkB;CACzD,OAAO;AACR;AAIA,SAAS,eAAe,UAA2B;CAClD,OAAO,aAAa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,GAE9B,OAAO,OAAO,KAAK,IAAI;UAEvB,OAAO,OAAO,GAAG;KAGlB,QAAQ,KAAK,MAAM;KACnB,SAAS,KAAA;KACT,aAAa,KAAA;KAEb;KACA,IAAI,UAAU,KAAK,SAAS,OAAO;IACpC;GACD;GAEA,IAAI,YAAY,QAAQ;IACvB,OAAO;IACP,WAAW;IACX,UAAU;IAEV;GACD;GAEA,IAAI,SAAS,SAAS,OAAO,GAAG;IAE/B,IAAI,aAAa,IAAI;KACpB,cAAc,aAAa,KAAK,QAAQ,UAAU,WAAW,CAAC,IAAI,KAAA;KAClE,UAAU,KAAA;IACX,OAAO;KACN,MAAM,iBAAiB,QAAQ,UAAU,GAAG,QAAQ;KACpD,MAAM,eAAe,QAAQ,GAAG;KAChC,cAAc,QAAQ,KAAK,eAAe,UAAU,MAAM,CAAC,IAAI,KAAA;KAC/D,UAAU,WAAW,QAAQ,SAAS,IAAI,QAAQ,UAAU,WAAW,CAAC,CAAC,CAAC,UAAU,IAAI,KAAA;IACzF;IAEA,SAAS,IAAI,gBAAgB,UAAU,KAAK,UAAU,IAAI,KAAK,IAAI,GAAG,SAAS,aAAa,OAAO;IACnG,aAAa;GACd;EACD;EAEA,IAAI,KAAK,EAAE,QAAQ,WAAW,QAAQ,OAAO,UAAU,CAAC;EAExD,OAAO;GACI;GACD;GACF;GACA;GACA;GACP,SAAU,UAAU,KAAK,SAAS,SAAW,eAAe,KAAK,SAAS;EAC3E;;;;;;AACD"}
@@ -16,7 +16,9 @@ export declare class BranchesGitSubProvider implements GitBranchesSubProvider {
16
16
  private readonly cache;
17
17
  private readonly provider;
18
18
  constructor(context: GitServiceContext, git: Git, cache: Cache, provider: CliGitProviderInternal);
19
- getBranch(repoPath: string, name?: string, cancellation?: AbortSignal): Promise<GitBranch | undefined>;
19
+ getBranch(repoPath: string, name?: string, options?: {
20
+ force?: boolean;
21
+ }, cancellation?: AbortSignal): Promise<GitBranch | undefined>;
20
22
  private getCurrentBranch;
21
23
  getBranches(repoPath: string, options?: {
22
24
  filter?: (b: GitBranch) => boolean;
@@ -59,6 +61,13 @@ export declare class BranchesGitSubProvider implements GitBranchesSubProvider {
59
61
  deleteLocalBranch(repoPath: string, names: string | string[], options?: {
60
62
  force?: boolean;
61
63
  }): Promise<void>;
64
+ /**
65
+ * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted
66
+ * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the
67
+ * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the
68
+ * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.
69
+ */
70
+ forgetDeletedBranch(repoPath: string, name: string): Promise<void>;
62
71
  /**
63
72
  * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only
64
73
  * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,
@@ -34,7 +34,8 @@ var BranchesGitSubProvider = class {
34
34
  this.cache = cache;
35
35
  this.provider = provider;
36
36
  }
37
- async getBranch(repoPath, name, cancellation) {
37
+ async getBranch(repoPath, name, options, cancellation) {
38
+ if (options?.force) this.cache.evictCaches(repoPath, "branches");
38
39
  if (name != null) {
39
40
  const { values: [branch] } = await this.getBranches(repoPath, { filter: (b) => b.name === name }, cancellation);
40
41
  return branch;
@@ -244,7 +245,7 @@ var BranchesGitSubProvider = class {
244
245
  if (mergeTarget == null && options?.associatedPullRequest != null) {
245
246
  const pr = await options.associatedPullRequest;
246
247
  if (pr?.refs?.base != null) {
247
- const branch = await this.getBranch(repoPath, ref, cancellation);
248
+ const branch = await this.getBranch(repoPath, ref, void 0, cancellation);
248
249
  if (branch == null) return void 0;
249
250
  mergeTarget = `${branch.remoteName}/${pr.refs.base.branch}`;
250
251
  if (pr.stack == null) this.storeMergeTargetBranchName(repoPath, ref, mergeTarget, { skipInvalidation: ["branchOverviews"] });
@@ -460,10 +461,7 @@ var BranchesGitSubProvider = class {
460
461
  ];
461
462
  try {
462
463
  await this.git.run({ cwd: repoPath }, ...args);
463
- for (const branch of branches) {
464
- this.cache.deleteBaseBranchName(repoPath, branch);
465
- await this.provider.config.removeGkConfigBranchSection(repoPath, branch);
466
- }
464
+ for (const branch of branches) await this.forgetDeletedBranch(repoPath, branch);
467
465
  this.context.hooks?.cache?.onReset?.(repoPath, "branches");
468
466
  this.context.hooks?.repository?.onChanged?.(repoPath, ["heads"]);
469
467
  } catch (ex) {
@@ -491,6 +489,16 @@ var BranchesGitSubProvider = class {
491
489
  }
492
490
  }
493
491
  /**
492
+ * Drops what GitLens keeps for a local branch beyond its ref, for both ways one is deleted
493
+ * (`deleteLocalBranch` and `refs.deleteReference`). The persisted gk metadata goes too, not just the
494
+ * cached resolution: `getBaseBranchName` reads `branch.<ref>.gk-merge-base` before falling back to the
495
+ * reflog, so leaving it behind would hand a later branch reusing this name its predecessor's base.
496
+ */
497
+ async forgetDeletedBranch(repoPath, name) {
498
+ this.cache.deleteBaseBranchName(repoPath, name);
499
+ await this.provider.config.removeGkConfigBranchSection(repoPath, name);
500
+ }
501
+ /**
494
502
  * Drops the cached and persisted per-branch metadata for whichever of `names` no longer exists. Only
495
503
  * for the partial-failure path — one extra `for-each-ref` is cheap while already handling an error,
496
504
  * and keeps the success path free of it.
@@ -511,8 +519,7 @@ var BranchesGitSubProvider = class {
511
519
  for (const name of names) {
512
520
  if (surviving.has(name)) continue;
513
521
  anyDeleted = true;
514
- this.cache.deleteBaseBranchName(repoPath, name);
515
- await this.provider.config.removeGkConfigBranchSection(repoPath, name);
522
+ await this.forgetDeletedBranch(repoPath, name);
516
523
  }
517
524
  return anyDeleted;
518
525
  } catch {
@@ -898,17 +905,15 @@ var BranchesGitSubProvider = class {
898
905
  const priority = options?.priority;
899
906
  const priorityOpts = priority != null ? { priority } : void 0;
900
907
  try {
901
- let result = await this.git.run({
902
- cwd: repoPath,
903
- cancellation,
904
- ...priorityOpts
905
- }, "reflog", ref, "--grep-reflog=branch: Created from *.");
906
- let entries = result.stdout.split("\n").filter((entry) => Boolean(entry));
908
+ let entries = await this.provider.refs.getReflogEntries(repoPath, ref, {
909
+ grep: "branch: Created from *.",
910
+ priority
911
+ }, cancellation);
907
912
  if (entries.length !== 1) return {
908
913
  branch: void 0,
909
914
  failed: false
910
915
  };
911
- let match = entries[0].match(/branch: Created from (.*)$/);
916
+ let match = entries[0].message.match(/branch: Created from (.*)$/);
912
917
  if (match?.length === 2) {
913
918
  let name = match[1];
914
919
  if (name !== "HEAD") {
@@ -926,17 +931,15 @@ var BranchesGitSubProvider = class {
926
931
  };
927
932
  }
928
933
  }
929
- result = await this.git.run({
930
- cwd: repoPath,
931
- cancellation,
932
- ...priorityOpts
933
- }, "reflog", "HEAD", `--grep-reflog=checkout: moving from .* to ${ref.replace("refs/heads/", "")}`);
934
- entries = result.stdout.split("\n").filter((entry) => Boolean(entry));
934
+ entries = await this.provider.refs.getReflogEntries(repoPath, "HEAD", {
935
+ grep: `checkout: moving from .* to ${ref.replace("refs/heads/", "")}`,
936
+ priority
937
+ }, cancellation);
935
938
  if (!entries.length) return {
936
939
  branch: void 0,
937
940
  failed: false
938
941
  };
939
- match = entries.at(-1).match(/checkout: moving from ([^\s]+)\s/);
942
+ match = entries.at(-1).message.match(/checkout: moving from ([^\s]+)\s/);
940
943
  if (match?.length === 2) {
941
944
  let name = match[1];
942
945
  if (options?.upstream) {
@@ -954,6 +957,12 @@ var BranchesGitSubProvider = class {
954
957
  }
955
958
  } catch (ex) {
956
959
  if (isCancellationError(ex)) throw ex;
960
+ const msg = ex?.toString() ?? "";
961
+ const stderr = ex instanceof GitError ? ex.stderr : void 0;
962
+ if ([GitErrors.badRevision, GitErrors.ambiguousArgument].some((error) => error.test(msg) || stderr != null && error.test(stderr))) return {
963
+ branch: void 0,
964
+ failed: false
965
+ };
957
966
  return {
958
967
  branch: void 0,
959
968
  failed: true