git-chopstick-core 0.1.2 → 0.1.4

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 (145) hide show
  1. package/README.md +42 -10
  2. package/dist/git/apply.d.ts +1 -1
  3. package/dist/git/apply.js +1 -1
  4. package/dist/git/apply.js.map +1 -1
  5. package/dist/git/environment.d.ts +1 -1
  6. package/dist/git/environment.js +1 -1
  7. package/dist/git/environment.js.map +1 -1
  8. package/dist/git/exec.js.map +1 -1
  9. package/dist/git/gitignore.js +1 -1
  10. package/dist/git/gitignore.js.map +1 -1
  11. package/dist/git/index.d.ts +1 -0
  12. package/dist/git/index.js +3 -0
  13. package/dist/git/index.js.map +1 -1
  14. package/dist/lib/fatal-error.d.ts +1 -1
  15. package/dist/lib/fatal-error.js +1 -1
  16. package/dist/lib/fatal-error.js.map +1 -1
  17. package/dist/lib/progress/from-process.js.map +1 -1
  18. package/dist/lib/progress/index.d.ts +5 -5
  19. package/dist/lib/progress/index.js +5 -5
  20. package/dist/lib/progress/index.js.map +1 -1
  21. package/dist/lib/progress/revert.d.ts +1 -1
  22. package/dist/lib/progress/revert.js +1 -1
  23. package/dist/lib/progress/revert.js.map +1 -1
  24. package/dist/lib/status-parser.js +0 -12
  25. package/dist/lib/status-parser.js.map +1 -1
  26. package/dist/models/repository.d.ts +1 -1
  27. package/dist/models/repository.js +1 -1
  28. package/dist/models/repository.js.map +1 -1
  29. package/package.json +39 -9
  30. package/src/git/add.ts +0 -16
  31. package/src/git/apply.ts +0 -154
  32. package/src/git/authentication.ts +0 -20
  33. package/src/git/branch.ts +0 -206
  34. package/src/git/checkout-index.ts +0 -40
  35. package/src/git/checkout.ts +0 -235
  36. package/src/git/cherry-pick.ts +0 -504
  37. package/src/git/clean.ts +0 -9
  38. package/src/git/clone.ts +0 -86
  39. package/src/git/coerce-to-buffer.ts +0 -4
  40. package/src/git/coerce-to-string.ts +0 -4
  41. package/src/git/commit.ts +0 -136
  42. package/src/git/config.ts +0 -392
  43. package/src/git/core.ts +0 -625
  44. package/src/git/create-tail-stream.ts +0 -36
  45. package/src/git/credential.ts +0 -83
  46. package/src/git/description.ts +0 -33
  47. package/src/git/diff-check.ts +0 -27
  48. package/src/git/diff-index.ts +0 -116
  49. package/src/git/diff.ts +0 -880
  50. package/src/git/environment.ts +0 -116
  51. package/src/git/exec.ts +0 -285
  52. package/src/git/fetch.ts +0 -141
  53. package/src/git/for-each-ref.ts +0 -160
  54. package/src/git/format-patch.ts +0 -17
  55. package/src/git/git-delimiter-parser.ts +0 -95
  56. package/src/git/gitignore.ts +0 -157
  57. package/src/git/index.ts +0 -46
  58. package/src/git/init.ts +0 -11
  59. package/src/git/interpret-trailers.ts +0 -176
  60. package/src/git/lfs.ts +0 -100
  61. package/src/git/log.ts +0 -376
  62. package/src/git/merge-tree.ts +0 -42
  63. package/src/git/merge.ts +0 -154
  64. package/src/git/multi-operation-terminal-output.ts +0 -68
  65. package/src/git/pull.ts +0 -130
  66. package/src/git/push-terminal-chunk.ts +0 -41
  67. package/src/git/push.ts +0 -119
  68. package/src/git/rebase.ts +0 -627
  69. package/src/git/reflog.ts +0 -127
  70. package/src/git/refs.ts +0 -63
  71. package/src/git/remote.ts +0 -143
  72. package/src/git/reorder.ts +0 -153
  73. package/src/git/reset.ts +0 -101
  74. package/src/git/rev-list.ts +0 -201
  75. package/src/git/rev-parse.ts +0 -92
  76. package/src/git/revert.ts +0 -55
  77. package/src/git/rm.ts +0 -31
  78. package/src/git/show.ts +0 -88
  79. package/src/git/spawn.ts +0 -38
  80. package/src/git/squash.ts +0 -173
  81. package/src/git/stage.ts +0 -97
  82. package/src/git/stash.ts +0 -302
  83. package/src/git/status.ts +0 -502
  84. package/src/git/submodule.ts +0 -212
  85. package/src/git/tag.ts +0 -134
  86. package/src/git/update-index.ts +0 -169
  87. package/src/git/update-ref.ts +0 -50
  88. package/src/git/var.ts +0 -42
  89. package/src/git/worktree-include.ts +0 -146
  90. package/src/git/worktree.ts +0 -219
  91. package/src/index.ts +0 -11
  92. package/src/lib/api.ts +0 -7
  93. package/src/lib/diff-parser.ts +0 -249
  94. package/src/lib/directory-exists.ts +0 -10
  95. package/src/lib/errno-exception.ts +0 -12
  96. package/src/lib/fatal-error.ts +0 -23
  97. package/src/lib/feature-flag.ts +0 -29
  98. package/src/lib/file-system.ts +0 -7
  99. package/src/lib/get-old-path.ts +0 -11
  100. package/src/lib/git/environment.ts +0 -14
  101. package/src/lib/git-perf.ts +0 -3
  102. package/src/lib/helpers/default-branch.ts +0 -3
  103. package/src/lib/helpers/path.ts +0 -5
  104. package/src/lib/hooks/with-hooks-env.ts +0 -7
  105. package/src/lib/merge.ts +0 -3
  106. package/src/lib/noop.ts +0 -1
  107. package/src/lib/patch-formatter.ts +0 -18
  108. package/src/lib/path-exists.ts +0 -7
  109. package/src/lib/progress/from-process.ts +0 -10
  110. package/src/lib/progress/index.ts +0 -43
  111. package/src/lib/progress/revert.ts +0 -17
  112. package/src/lib/rebase.ts +0 -3
  113. package/src/lib/remove-remote-prefix.ts +0 -4
  114. package/src/lib/resolve-git-proxy.ts +0 -3
  115. package/src/lib/round.ts +0 -4
  116. package/src/lib/split-buffer.ts +0 -14
  117. package/src/lib/status-parser.ts +0 -188
  118. package/src/lib/stores/helpers/find-default-remote.ts +0 -3
  119. package/src/lib/trampoline/trampoline-environment.ts +0 -8
  120. package/src/models/branch.ts +0 -78
  121. package/src/models/cherry-pick.ts +0 -12
  122. package/src/models/clone-options.ts +0 -6
  123. package/src/models/commit-identity.ts +0 -35
  124. package/src/models/commit.ts +0 -44
  125. package/src/models/computed-action.ts +0 -6
  126. package/src/models/diff/diff-data.ts +0 -78
  127. package/src/models/diff/diff-line.ts +0 -36
  128. package/src/models/diff/diff-selection.ts +0 -165
  129. package/src/models/diff/image-diff.ts +0 -6
  130. package/src/models/diff/image.ts +0 -8
  131. package/src/models/diff/index.ts +0 -6
  132. package/src/models/diff/raw-diff.ts +0 -41
  133. package/src/models/git-author.ts +0 -16
  134. package/src/models/index.ts +0 -36
  135. package/src/models/manual-conflict-resolution.ts +0 -4
  136. package/src/models/merge.ts +0 -6
  137. package/src/models/multi-commit-operation.ts +0 -6
  138. package/src/models/progress.ts +0 -67
  139. package/src/models/rebase.ts +0 -20
  140. package/src/models/remote.ts +0 -10
  141. package/src/models/repository.ts +0 -16
  142. package/src/models/stash-entry.ts +0 -25
  143. package/src/models/status.ts +0 -275
  144. package/src/models/submodule.ts +0 -13
  145. package/src/models/worktree.ts +0 -11
@@ -1,219 +0,0 @@
1
- import { git } from './core.js'
2
- import { Repository } from '../models/repository.js'
3
- import * as Path from 'path'
4
- import * as Fs from 'fs'
5
- import type { WorktreeEntry, WorktreeType } from '../models/worktree.js'
6
- import { normalizePath } from '../lib/helpers/path.js'
7
-
8
- /**
9
- * Get the set of canonical branch refs (e.g. `refs/heads/feature`)
10
- * checked out in any worktree (main or linked).
11
- */
12
- export async function getWorktreeCheckedOutBranches(
13
- repository: Repository
14
- ): Promise<ReadonlySet<string>> {
15
- const result = await git(
16
- ['worktree', 'list', '--porcelain', '-z'],
17
- repository.path,
18
- 'getWorktreeCheckedOutBranches'
19
- )
20
-
21
- const branches = new Set<string>()
22
-
23
- // With -z, lines are NUL-terminated and blocks are separated by
24
- // double NUL (i.e. an empty string between two NUL terminators).
25
- const blocks = result.stdout.split('\0\0')
26
-
27
- for (const block of blocks) {
28
- for (const line of block.split('\0')) {
29
- if (line.startsWith('branch ')) {
30
- branches.add(line.substring('branch '.length))
31
- }
32
- }
33
- }
34
-
35
- return branches
36
- }
37
-
38
- function getDotGitPath(repositoryPath: string): string {
39
- return Path.join(repositoryPath, '.git')
40
- }
41
-
42
- export interface IWorktreePathInfo {
43
- readonly isLinkedWorktree: boolean
44
- readonly mainWorktreePath: string | null
45
- }
46
-
47
- export function parseWorktreePorcelainOutput(
48
- stdout: string
49
- ): ReadonlyArray<WorktreeEntry> {
50
- if (stdout.trim().length === 0) {
51
- return []
52
- }
53
-
54
- const blocks = stdout.trim().split('\n\n')
55
- const entries: WorktreeEntry[] = []
56
-
57
- for (let i = 0; i < blocks.length; i++) {
58
- const lines = blocks[i].split('\n')
59
- let path = ''
60
- let head = ''
61
- let branch: string | null = null
62
- let isDetached = false
63
- let isLocked = false
64
- let isPrunable = false
65
-
66
- for (const line of lines) {
67
- if (line.startsWith('worktree ')) {
68
- path = line.substring('worktree '.length)
69
- } else if (line.startsWith('HEAD ')) {
70
- head = line.substring('HEAD '.length)
71
- } else if (line.startsWith('branch ')) {
72
- branch = line.substring('branch '.length)
73
- } else if (line === 'detached') {
74
- isDetached = true
75
- } else if (line === 'locked' || line.startsWith('locked ')) {
76
- isLocked = true
77
- } else if (line === 'prunable' || line.startsWith('prunable ')) {
78
- isPrunable = true
79
- }
80
- }
81
-
82
- const type: WorktreeType = i === 0 ? 'main' : 'linked'
83
- entries.push({ path, head, branch, isDetached, type, isLocked, isPrunable })
84
- }
85
-
86
- return entries
87
- }
88
-
89
- export async function listWorktrees(
90
- repository: Repository
91
- ): Promise<ReadonlyArray<WorktreeEntry>> {
92
- const result = await git(
93
- ['worktree', 'list', '--porcelain'],
94
- repository.path,
95
- 'listWorktrees'
96
- )
97
-
98
- return parseWorktreePorcelainOutput(result.stdout)
99
- }
100
-
101
- export async function addWorktree(
102
- repository: Repository,
103
- path: string,
104
- options: {
105
- readonly branch?: string
106
- readonly createBranch?: string
107
- readonly detach?: boolean
108
- readonly commitish?: string
109
- } = {}
110
- ): Promise<void> {
111
- const args = ['worktree', 'add']
112
-
113
- if (options.detach) {
114
- args.push('--detach')
115
- }
116
-
117
- if (options.createBranch) {
118
- args.push('-b', options.createBranch)
119
- }
120
-
121
- args.push(path)
122
-
123
- if (options.branch) {
124
- args.push(options.branch)
125
- } else if (options.commitish) {
126
- args.push(options.commitish)
127
- }
128
-
129
- await git(args, repository.path, 'addWorktree')
130
- }
131
-
132
- export async function removeWorktree(
133
- repository: Repository,
134
- path: string
135
- ): Promise<void> {
136
- const args = ['worktree', 'remove', '--force', path]
137
- await git(args, repository.path, 'removeWorktree')
138
- }
139
-
140
- export async function pruneWorktrees(repository: Repository): Promise<void> {
141
- await git(['worktree', 'prune'], repository.path, 'pruneWorktrees')
142
- }
143
-
144
- export async function moveWorktree(
145
- repository: Repository,
146
- oldPath: string,
147
- newPath: string
148
- ): Promise<void> {
149
- await git(
150
- ['worktree', 'move', oldPath, newPath],
151
- repository.path,
152
- 'moveWorktree'
153
- )
154
- }
155
-
156
- export async function isLinkedWorktree(
157
- repository: Repository
158
- ): Promise<boolean> {
159
- const worktrees = await listWorktrees(repository)
160
- const repoPath = normalizePath(repository.path)
161
-
162
- return worktrees.some(
163
- wt => wt.type === 'linked' && normalizePath(wt.path) === repoPath
164
- )
165
- }
166
-
167
- export async function getMainWorktreePath(
168
- repository: Repository
169
- ): Promise<string | null> {
170
- const worktrees = await listWorktrees(repository)
171
- const main = worktrees.find(wt => wt.type === 'main')
172
- return main?.path ?? null
173
- }
174
-
175
- export function getWorktreePathInfoSync(
176
- repositoryPath: string
177
- ): IWorktreePathInfo | null {
178
- try {
179
- const dotGit = getDotGitPath(repositoryPath)
180
- // eslint-disable-next-line no-sync
181
- const stats = Fs.statSync(dotGit)
182
-
183
- if (stats.isDirectory()) {
184
- return { isLinkedWorktree: false, mainWorktreePath: repositoryPath }
185
- }
186
-
187
- if (!stats.isFile()) {
188
- return null
189
- }
190
-
191
- // eslint-disable-next-line no-sync
192
- const contents = Fs.readFileSync(dotGit, 'utf8').trim()
193
- if (!contents.startsWith('gitdir: ')) {
194
- return null
195
- }
196
-
197
- const gitDirPath = Path.resolve(
198
- repositoryPath,
199
- contents.substring('gitdir: '.length)
200
- )
201
-
202
- // eslint-disable-next-line no-sync
203
- const commondir = Fs.readFileSync(
204
- Path.join(gitDirPath, 'commondir'),
205
- 'utf8'
206
- ).trim()
207
- if (commondir.length === 0) {
208
- return null
209
- }
210
-
211
- const commonGitDir = Path.resolve(gitDirPath, commondir)
212
- return {
213
- isLinkedWorktree: true,
214
- mainWorktreePath: Path.dirname(commonGitDir),
215
- }
216
- } catch {
217
- return null
218
- }
219
- }
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- // ── All git operations ──
2
- export * from './git/index.js'
3
-
4
- // ── Git error codes enum (renamed to avoid conflict with GitError class from core.js) ──
5
- export { GitError as GitErrorCodes, type IGitSpawnOptions } from './git/exec.js'
6
-
7
- // ── All domain models ──
8
- export * from './models/index.js'
9
-
10
- // ── Explicit re-exports to resolve ambiguities between git and models ──
11
- export type { ITrailer } from './models/commit.js'
package/src/lib/api.ts DELETED
@@ -1,7 +0,0 @@
1
- export function getHTMLURL(): string {
2
- return 'https://github.com'
3
- }
4
-
5
- export function isTrustedRemoteHost(_url: string): boolean {
6
- return true
7
- }
@@ -1,249 +0,0 @@
1
- import {
2
- IRawDiff,
3
- DiffHunk,
4
- DiffHunkHeader,
5
- DiffLine,
6
- DiffLineType,
7
- DiffHunkExpansionType,
8
- } from '../models/diff/index.js'
9
- import { assertNever } from './fatal-error.js'
10
-
11
- const diffHeaderRe = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/
12
-
13
- export const HiddenBidiCharsRegex = /[\u202A-\u202E]|[\u2066-\u2069]/
14
-
15
- const DiffPrefixAdd = '+' as const
16
- const DiffPrefixDelete = '-' as const
17
- const DiffPrefixContext = ' ' as const
18
- const DiffPrefixNoNewline = '\\' as const
19
-
20
- type DiffLinePrefix =
21
- | typeof DiffPrefixAdd
22
- | typeof DiffPrefixDelete
23
- | typeof DiffPrefixContext
24
- | typeof DiffPrefixNoNewline
25
-
26
- const DiffLinePrefixChars: Set<DiffLinePrefix> = new Set([
27
- DiffPrefixAdd,
28
- DiffPrefixDelete,
29
- DiffPrefixContext,
30
- DiffPrefixNoNewline,
31
- ])
32
-
33
- interface IDiffHeaderInfo {
34
- readonly isBinary: boolean
35
- }
36
-
37
- function getLargestLineNumber(hunks: ReadonlyArray<DiffHunk>): number {
38
- let largest = 0
39
- for (const hunk of hunks) {
40
- for (const line of hunk.lines) {
41
- if (line.originalLineNumber !== null && line.originalLineNumber > largest) {
42
- largest = line.originalLineNumber
43
- }
44
- }
45
- }
46
- return largest
47
- }
48
-
49
- function getHunkHeaderExpansionType(
50
- _hunkIndex: number,
51
- _header: DiffHunkHeader,
52
- _previousHunk: DiffHunk | null
53
- ): DiffHunkExpansionType {
54
- return DiffHunkExpansionType.None
55
- }
56
-
57
- export class DiffParser {
58
- private ls!: number
59
- private le!: number
60
- private text!: string
61
-
62
- public constructor() {
63
- this.reset()
64
- }
65
-
66
- private reset() {
67
- this.ls = 0
68
- this.le = -1
69
- this.text = ''
70
- }
71
-
72
- private nextLine(): boolean {
73
- this.ls = this.le + 1
74
- if (this.ls >= this.text.length) return false
75
- this.le = this.text.indexOf('\n', this.ls)
76
- if (this.le === -1) this.le = this.text.length
77
- return this.ls !== this.le
78
- }
79
-
80
- private readLine(): string | null {
81
- return this.nextLine() ? this.text.substring(this.ls, this.le) : null
82
- }
83
-
84
- private lineStartsWith(searchString: string): boolean {
85
- return this.text.startsWith(searchString, this.ls)
86
- }
87
-
88
- private lineEndsWith(searchString: string): boolean {
89
- return this.text.endsWith(searchString, this.le)
90
- }
91
-
92
- private peek(): string | null {
93
- const p = this.le + 1
94
- return p < this.text.length ? this.text[p] : null
95
- }
96
-
97
- private parseDiffHeader(): IDiffHeaderInfo | null {
98
- while (this.nextLine()) {
99
- if (this.lineStartsWith('Binary files ') && this.lineEndsWith('differ')) {
100
- return { isBinary: true }
101
- }
102
- if (this.lineStartsWith('+++')) {
103
- return { isBinary: false }
104
- }
105
- }
106
- return null
107
- }
108
-
109
- private numberFromGroup(
110
- m: RegExpMatchArray,
111
- group: number,
112
- defaultValue: number | null = null
113
- ): number {
114
- const str = m[group]
115
- if (!str) {
116
- if (defaultValue === null) {
117
- throw new Error(
118
- `Group ${group} missing from regexp match and no defaultValue was provided`
119
- )
120
- }
121
- return defaultValue
122
- }
123
- const num = parseInt(str, 10)
124
- if (isNaN(num)) {
125
- throw new Error(`Could not parse capture group ${group} into number: ${str}`)
126
- }
127
- return num
128
- }
129
-
130
- private parseHunkHeader(line: string): DiffHunkHeader {
131
- const m = diffHeaderRe.exec(line)
132
- if (!m) throw new Error('Invalid hunk header format')
133
-
134
- const oldStartLine = this.numberFromGroup(m, 1)
135
- const oldLineCount = this.numberFromGroup(m, 2, 1)
136
- const newStartLine = this.numberFromGroup(m, 3)
137
- const newLineCount = this.numberFromGroup(m, 4, 1)
138
-
139
- return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount)
140
- }
141
-
142
- private parseLinePrefix(c: string | null): DiffLinePrefix | null {
143
- if (c && c.length && (DiffLinePrefixChars as Set<string>).has(c[0])) {
144
- return c[0] as DiffLinePrefix
145
- }
146
- return null
147
- }
148
-
149
- private parseHunk(
150
- linesConsumed: number,
151
- _hunkIndex: number,
152
- _previousHunk: DiffHunk | null
153
- ): DiffHunk {
154
- const headerLine = this.readLine()
155
- if (!headerLine) throw new Error('Expected hunk header but reached end of diff')
156
-
157
- const header = this.parseHunkHeader(headerLine)
158
- const lines = new Array<DiffLine>()
159
- lines.push(new DiffLine(headerLine, DiffLineType.Hunk, 1, null, null))
160
-
161
- let rollingDiffBeforeCounter = header.oldStartLine
162
- let rollingDiffAfterCounter = header.newStartLine
163
- let diffLineNumber = linesConsumed
164
-
165
- let c: DiffLinePrefix | null
166
- while ((c = this.parseLinePrefix(this.peek()))) {
167
- const line = this.readLine()
168
- if (!line) throw new Error('Expected unified diff line but reached end of diff')
169
-
170
- if (c === DiffPrefixNoNewline) {
171
- if (line.length < 12) {
172
- throw new Error(
173
- `Expected "no newline at end of file" marker to be at least 12 bytes long`
174
- )
175
- }
176
- const previousLineIndex = lines.length - 1
177
- lines[previousLineIndex] = lines[previousLineIndex].withNoTrailingNewLine(true)
178
- continue
179
- }
180
-
181
- diffLineNumber++
182
-
183
- let diffLine: DiffLine
184
- if (c === DiffPrefixAdd) {
185
- diffLine = new DiffLine(line, DiffLineType.Add, diffLineNumber, null, rollingDiffAfterCounter++)
186
- } else if (c === DiffPrefixDelete) {
187
- diffLine = new DiffLine(line, DiffLineType.Delete, diffLineNumber, rollingDiffBeforeCounter++, null)
188
- } else if (c === DiffPrefixContext) {
189
- diffLine = new DiffLine(line, DiffLineType.Context, diffLineNumber, rollingDiffBeforeCounter++, rollingDiffAfterCounter++)
190
- } else {
191
- return assertNever(c, `Unknown DiffLinePrefix: ${c}`)
192
- }
193
- lines.push(diffLine)
194
- }
195
-
196
- if (lines.length === 1) {
197
- throw new Error('Malformed diff, empty hunk')
198
- }
199
-
200
- return new DiffHunk(
201
- header,
202
- lines,
203
- linesConsumed,
204
- linesConsumed + lines.length - 1,
205
- getHunkHeaderExpansionType(_hunkIndex, header, _previousHunk)
206
- )
207
- }
208
-
209
- public parse(text: string): IRawDiff {
210
- this.text = text
211
- try {
212
- const headerInfo = this.parseDiffHeader()
213
- const headerEnd = this.le
214
- const header = this.text.substring(0, headerEnd)
215
-
216
- if (!headerInfo) {
217
- return { header, contents: '', hunks: [], isBinary: false, maxLineNumber: 0, hasHiddenBidiChars: false }
218
- }
219
-
220
- if (headerInfo.isBinary) {
221
- return { header, contents: '', hunks: [], isBinary: true, maxLineNumber: 0, hasHiddenBidiChars: false }
222
- }
223
-
224
- const hunks = new Array<DiffHunk>()
225
- let linesConsumed = 0
226
-
227
- do {
228
- const hunk = this.parseHunk(linesConsumed, hunks.length, null)
229
- hunks.push(hunk)
230
- linesConsumed += hunk.lines.length
231
- } while (this.peek())
232
-
233
- const contents = this.text
234
- .substring(headerEnd + 1, this.le)
235
- .replace(/\n\/g, '')
236
-
237
- return {
238
- header,
239
- contents,
240
- hunks,
241
- isBinary: headerInfo.isBinary,
242
- maxLineNumber: getLargestLineNumber(hunks),
243
- hasHiddenBidiChars: HiddenBidiCharsRegex.test(text),
244
- }
245
- } finally {
246
- this.reset()
247
- }
248
- }
249
- }
@@ -1,10 +0,0 @@
1
- import { stat } from 'fs/promises'
2
-
3
- export const directoryExists = async (path: string) => {
4
- try {
5
- const s = await stat(path)
6
- return s.isDirectory()
7
- } catch {
8
- return false
9
- }
10
- }
@@ -1,12 +0,0 @@
1
- interface IErrnoException extends Error {
2
- readonly code: string
3
- readonly syscall: string
4
- }
5
-
6
- export function isErrnoException(err: any): err is IErrnoException {
7
- return (
8
- err instanceof Error &&
9
- typeof (err as any).code === 'string' &&
10
- typeof (err as any).syscall === 'string'
11
- )
12
- }
@@ -1,23 +0,0 @@
1
- export function fatalError(msg: string): never {
2
- throw new Error(msg)
3
- }
4
-
5
- export function assertNever(x: never, message: string): never {
6
- throw new Error(message)
7
- }
8
-
9
- export function forceUnwrap<T>(message: string, x: T | null | undefined): T {
10
- if (x == null) {
11
- return fatalError(message)
12
- }
13
- return x
14
- }
15
-
16
- export function assertNonNullable<T>(
17
- x: T,
18
- message: string
19
- ): asserts x is NonNullable<T> {
20
- if (x == null) {
21
- return fatalError(message)
22
- }
23
- }
@@ -1,29 +0,0 @@
1
- export function enableImagePreviewsForDDSFiles(): boolean {
2
- return false
3
- }
4
-
5
- export function enableReadmeOverwriteWarning(): boolean {
6
- return false
7
- }
8
-
9
- export function enableWSLDetection(): boolean {
10
- return false
11
- }
12
-
13
- export function enablePreviousTagSuggestions(): boolean {
14
- return false
15
- }
16
-
17
- export function enablePullRequestQuickView(): boolean {
18
- return false
19
- }
20
-
21
- export const enableCustomIntegration = () => true
22
- export const enableResizingToolbarButtons = () => true
23
- export const enableHooksEnvironment = () => true
24
- export const enableHooksByDefault = () => true
25
- export const enableFormattingPreferences = () => true
26
- export const enableCopilotConflictResolution = () => false
27
- export const enableTestMenuItems = () => false
28
- export const enableCommitMessageGeneration = () => false
29
- export const enableCopilotSdkCommitMessageGeneration = () => false
@@ -1,7 +0,0 @@
1
- import { mkdtempSync } from 'fs'
2
- import { tmpdir } from 'os'
3
- import { join } from 'path'
4
-
5
- export function getTempFilePath(prefix: string): string {
6
- return join(mkdtempSync(join(tmpdir(), prefix)), 'temp')
7
- }
@@ -1,11 +0,0 @@
1
- import { FileChange, AppFileStatusKind } from '../models/status.js'
2
-
3
- export function getOldPathOrDefault(file: FileChange) {
4
- if (
5
- file.status.kind === AppFileStatusKind.Renamed ||
6
- file.status.kind === AppFileStatusKind.Copied
7
- ) {
8
- return file.status.oldPath
9
- }
10
- return file.path
11
- }
@@ -1,14 +0,0 @@
1
- import { IRemote } from '../../models/remote.js'
2
-
3
- export async function envForRemoteOperation(
4
- _url: string | null
5
- ): Promise<Record<string, string | undefined>> {
6
- return {}
7
- }
8
-
9
- export function getFallbackUrlForProxyResolve(
10
- _repository: any,
11
- _remote: IRemote | null
12
- ): string | null {
13
- return null
14
- }
@@ -1,3 +0,0 @@
1
- export function measure<T>(_name: string, fn: () => Promise<T>): Promise<T> {
2
- return fn()
3
- }
@@ -1,3 +0,0 @@
1
- export async function getDefaultBranch(): Promise<string> {
2
- return 'main'
3
- }
@@ -1,5 +0,0 @@
1
- import * as Path from 'path'
2
-
3
- export function normalizePath(path: string): string {
4
- return Path.normalize(path)
5
- }
@@ -1,7 +0,0 @@
1
- export function withHooksEnv<T>(
2
- fn: (env: Record<string, string | undefined>) => Promise<T>,
3
- _path: string,
4
- _options?: { interceptHooks?: string[] }
5
- ): Promise<T> {
6
- return fn({})
7
- }
package/src/lib/merge.ts DELETED
@@ -1,3 +0,0 @@
1
- export function merge<T, U>(a: T, b: U): T & U {
2
- return { ...a, ...b }
3
- }
package/src/lib/noop.ts DELETED
@@ -1 +0,0 @@
1
- export default function noop() {}
@@ -1,18 +0,0 @@
1
- import { DiffSelection } from '../models/diff/index.js'
2
- import { WorkingDirectoryFileChange } from '../models/status.js'
3
- import { Repository } from '../models/repository.js'
4
-
5
- export async function formatPatch(
6
- _repository: Repository,
7
- _file: WorkingDirectoryFileChange,
8
- _selection: DiffSelection
9
- ): Promise<string> {
10
- return ''
11
- }
12
-
13
- export async function formatPatchToDiscardChanges(
14
- _repository: Repository,
15
- _file: WorkingDirectoryFileChange
16
- ): Promise<string> {
17
- return ''
18
- }
@@ -1,7 +0,0 @@
1
- import { access } from 'fs/promises'
2
-
3
- export const pathExists = (path: string) =>
4
- access(path).then(
5
- () => true,
6
- () => false
7
- )
@@ -1,10 +0,0 @@
1
- import { ChildProcess } from 'child_process'
2
- import { IGitExecutionOptions } from '../../git/core.js'
3
-
4
- export async function executionOptionsWithProgress(
5
- options: IGitExecutionOptions,
6
- _parser: any,
7
- _progressCallback: (progress: any) => void
8
- ): Promise<IGitExecutionOptions> {
9
- return options
10
- }