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,165 +0,0 @@
1
- export enum DiffSelectionType {
2
- All = 'All',
3
- Partial = 'Partial',
4
- None = 'None',
5
- }
6
-
7
- function typeMatchesSelection(
8
- selectionType: DiffSelectionType,
9
- selected: boolean
10
- ): boolean {
11
- switch (selectionType) {
12
- case DiffSelectionType.All:
13
- return selected
14
- case DiffSelectionType.None:
15
- return !selected
16
- case DiffSelectionType.Partial:
17
- return false
18
- }
19
- }
20
-
21
- export class DiffSelection {
22
- public static fromInitialSelection(
23
- initialSelection: DiffSelectionType.All | DiffSelectionType.None
24
- ): DiffSelection {
25
- return new DiffSelection(initialSelection, null, null)
26
- }
27
-
28
- private constructor(
29
- private readonly defaultSelectionType: DiffSelectionType.All | DiffSelectionType.None,
30
- private readonly divergingLines: Set<number> | null = null,
31
- private readonly selectableLines: Set<number> | null = null
32
- ) {}
33
-
34
- public getSelectionType(): DiffSelectionType {
35
- const divergingLines = this.divergingLines
36
- const selectableLines = this.selectableLines
37
-
38
- if (!divergingLines || divergingLines.size === 0) {
39
- return this.defaultSelectionType
40
- }
41
-
42
- if (selectableLines && selectableLines.size === divergingLines.size) {
43
- const allSelectableLinesAreDivergent = [...selectableLines].every(i =>
44
- divergingLines.has(i)
45
- )
46
- if (allSelectableLinesAreDivergent) {
47
- return this.defaultSelectionType === DiffSelectionType.All
48
- ? DiffSelectionType.None
49
- : DiffSelectionType.All
50
- }
51
- }
52
-
53
- return DiffSelectionType.Partial
54
- }
55
-
56
- public isSelected(lineIndex: number): boolean {
57
- const lineIsDivergent =
58
- !!this.divergingLines && this.divergingLines.has(lineIndex)
59
-
60
- if (this.defaultSelectionType === DiffSelectionType.All) {
61
- return !lineIsDivergent
62
- }
63
- return lineIsDivergent
64
- }
65
-
66
- public isRangeSelected(from: number, length: number): DiffSelectionType {
67
- if (length <= 0) return DiffSelectionType.None
68
-
69
- const computedSelectionType = this.getSelectionType()
70
- if (computedSelectionType !== DiffSelectionType.Partial) {
71
- return computedSelectionType
72
- }
73
-
74
- if (length === 1) {
75
- return this.isSelected(from) ? DiffSelectionType.All : DiffSelectionType.None
76
- }
77
-
78
- const to = from + length
79
- let foundSelected = false
80
- let foundDeselected = false
81
- for (let i = from; i < to; i++) {
82
- if (this.isSelected(i)) foundSelected = true
83
- if (!this.isSelected(i)) foundDeselected = true
84
- if (foundSelected && foundDeselected) return DiffSelectionType.Partial
85
- }
86
-
87
- return foundSelected ? DiffSelectionType.All : DiffSelectionType.None
88
- }
89
-
90
- public isSelectable(lineIndex: number): boolean {
91
- return this.selectableLines ? this.selectableLines.has(lineIndex) : true
92
- }
93
-
94
- public withLineSelection(lineIndex: number, selected: boolean): DiffSelection {
95
- return this.withRangeSelection(lineIndex, 1, selected)
96
- }
97
-
98
- public withRangeSelection(from: number, length: number, selected: boolean): DiffSelection {
99
- const computedSelectionType = this.getSelectionType()
100
- const to = from + length
101
-
102
- if (typeMatchesSelection(computedSelectionType, selected)) {
103
- return this
104
- }
105
-
106
- if (computedSelectionType === DiffSelectionType.Partial) {
107
- const newDivergingLines = new Set<number>(this.divergingLines!)
108
-
109
- if (typeMatchesSelection(this.defaultSelectionType, selected)) {
110
- for (let i = from; i < to; i++) {
111
- newDivergingLines.delete(i)
112
- }
113
- } else {
114
- for (let i = from; i < to; i++) {
115
- if (this.isSelectable(i)) {
116
- newDivergingLines.add(i)
117
- }
118
- }
119
- }
120
-
121
- return new DiffSelection(
122
- this.defaultSelectionType,
123
- newDivergingLines.size === 0 ? null : newDivergingLines,
124
- this.selectableLines
125
- )
126
- }
127
-
128
- const newDivergingLines = new Set<number>()
129
- for (let i = from; i < to; i++) {
130
- if (this.isSelectable(i)) {
131
- newDivergingLines.add(i)
132
- }
133
- }
134
-
135
- return new DiffSelection(
136
- computedSelectionType,
137
- newDivergingLines,
138
- this.selectableLines
139
- )
140
- }
141
-
142
- public withToggleLineSelection(lineIndex: number): DiffSelection {
143
- return this.withLineSelection(lineIndex, !this.isSelected(lineIndex))
144
- }
145
-
146
- public withSelectAll(): DiffSelection {
147
- return new DiffSelection(DiffSelectionType.All, null, this.selectableLines)
148
- }
149
-
150
- public withSelectNone(): DiffSelection {
151
- return new DiffSelection(DiffSelectionType.None, null, this.selectableLines)
152
- }
153
-
154
- public withSelectableLines(selectableLines: Set<number>) {
155
- const divergingLines = this.divergingLines
156
- ? new Set([...this.divergingLines].filter(x => selectableLines.has(x)))
157
- : null
158
-
159
- return new DiffSelection(
160
- this.defaultSelectionType,
161
- divergingLines,
162
- selectableLines
163
- )
164
- }
165
- }
@@ -1,6 +0,0 @@
1
- export enum ImageDiffType {
2
- TwoUp,
3
- Swipe,
4
- OnionSkin,
5
- Difference,
6
- }
@@ -1,8 +0,0 @@
1
- export class Image {
2
- public constructor(
3
- public readonly rawContents: ArrayBufferLike,
4
- public readonly contents: string,
5
- public readonly mediaType: string,
6
- public readonly bytes: number
7
- ) {}
8
- }
@@ -1,6 +0,0 @@
1
- export * from './diff-data.js'
2
- export * from './diff-line.js'
3
- export * from './diff-selection.js'
4
- export * from './image.js'
5
- export * from './raw-diff.js'
6
- export * from './image-diff.js'
@@ -1,41 +0,0 @@
1
- import { DiffLine } from './diff-line.js'
2
-
3
- export enum DiffHunkExpansionType {
4
- None = 'None',
5
- Up = 'Up',
6
- Down = 'Down',
7
- Both = 'Both',
8
- Short = 'Short',
9
- }
10
-
11
- export class DiffHunk {
12
- public constructor(
13
- public readonly header: DiffHunkHeader,
14
- public readonly lines: ReadonlyArray<DiffLine>,
15
- public readonly unifiedDiffStart: number,
16
- public readonly unifiedDiffEnd: number,
17
- public readonly expansionType: DiffHunkExpansionType
18
- ) {}
19
- }
20
-
21
- export class DiffHunkHeader {
22
- public constructor(
23
- public readonly oldStartLine: number,
24
- public readonly oldLineCount: number,
25
- public readonly newStartLine: number,
26
- public readonly newLineCount: number
27
- ) {}
28
-
29
- public toDiffLineRepresentation() {
30
- return `@@ -${this.oldStartLine},${this.oldLineCount} +${this.newStartLine},${this.newLineCount} @@`
31
- }
32
- }
33
-
34
- export interface IRawDiff {
35
- readonly header: string
36
- readonly contents: string
37
- readonly hunks: ReadonlyArray<DiffHunk>
38
- readonly isBinary: boolean
39
- readonly maxLineNumber: number
40
- readonly hasHiddenBidiChars: boolean
41
- }
@@ -1,16 +0,0 @@
1
- export class GitAuthor {
2
- public static parse(value: string): GitAuthor | null {
3
- const m = value.match(/^(.*?)\s*<(.+?)>\s*$/)
4
- if (!m) return null
5
- return new GitAuthor(m[1], m[2])
6
- }
7
-
8
- public constructor(
9
- public readonly name: string,
10
- public readonly email: string
11
- ) {}
12
-
13
- public toString(): string {
14
- return `${this.name} <${this.email}>`
15
- }
16
- }
@@ -1,36 +0,0 @@
1
- export * from './branch.js'
2
- export * from './cherry-pick.js'
3
- export * from './clone-options.js'
4
- export * from './commit.js'
5
- export * from './commit-identity.js'
6
- export * from './git-author.js'
7
- export * from './manual-conflict-resolution.js'
8
- export * from './merge.js'
9
- export * from './multi-commit-operation.js'
10
- export * from './progress.js'
11
- export * from './remote.js'
12
- export * from './repository.js'
13
- export * from './stash-entry.js'
14
- export * from './worktree.js'
15
- export * from './diff/index.js'
16
-
17
- // computed-action and rebase both export ComputedAction — use explicit exports
18
- export { ComputedAction } from './computed-action.js'
19
- export type { RebaseInternalState, RebaseProgressOptions } from './rebase.js'
20
-
21
- // status and submodule both export SubmoduleStatus — use explicit exports
22
- export {
23
- AppFileStatusKind,
24
- CommittedFileChange,
25
- WorkingDirectoryFileChange,
26
- WorkingDirectoryStatus,
27
- FileChange,
28
- isConflictedFileStatus,
29
- isConflictWithMarkers,
30
- GitStatusEntry,
31
- UnmergedEntrySummary,
32
- } from './status.js'
33
- export type { AppFileStatus } from './status.js'
34
- export type { SubmoduleStatus } from './status.js'
35
-
36
- export type { SubmoduleEntry } from './submodule.js'
@@ -1,4 +0,0 @@
1
- export enum ManualConflictResolution {
2
- theirs = 'theirs',
3
- ours = 'ours',
4
- }
@@ -1,6 +0,0 @@
1
- export type MergeTreeResult = {
2
- readonly sha: string
3
- readonly tree: string
4
- readonly conflicted: boolean
5
- readonly mergeBase: string
6
- }
@@ -1,6 +0,0 @@
1
- export enum MultiCommitOperationKind {
2
- Squash = 'Squash',
3
- Reorder = 'Reorder',
4
- CherryPick = 'CherryPick',
5
- Amend = 'Amend',
6
- }
@@ -1,67 +0,0 @@
1
- interface IProgress {
2
- readonly value: number
3
- readonly title?: string
4
- readonly description?: string
5
- }
6
-
7
- export interface IGenericProgress extends IProgress {
8
- kind: 'generic'
9
- }
10
-
11
- export interface ICheckoutProgress extends IProgress {
12
- kind: 'checkout'
13
- readonly target: string
14
- readonly description: string
15
- }
16
-
17
- export interface IFetchProgress extends IProgress {
18
- kind: 'fetch'
19
- readonly remote: string
20
- }
21
-
22
- export interface IPullProgress extends IProgress {
23
- kind: 'pull'
24
- readonly remote: string
25
- }
26
-
27
- export interface IPushProgress extends IProgress {
28
- kind: 'push'
29
- readonly remote: string
30
- readonly branch: string
31
- }
32
-
33
- export interface ICloneProgress extends IProgress {
34
- kind: 'clone'
35
- }
36
-
37
- export interface IRevertProgress extends IProgress {
38
- kind: 'revert'
39
- }
40
-
41
- export interface IMultiCommitOperationProgress extends IProgress {
42
- readonly kind: 'multiCommitOperation'
43
- readonly currentCommitSummary: string
44
- readonly position: number
45
- readonly totalCommitCount: number
46
- }
47
-
48
- export type Progress =
49
- | IGenericProgress
50
- | ICheckoutProgress
51
- | IFetchProgress
52
- | IPullProgress
53
- | IPushProgress
54
- | IRevertProgress
55
- | IMultiCommitOperationProgress
56
-
57
- export function clampProgress<T extends Progress>(
58
- minimum: number,
59
- maximum: number,
60
- progressCallback: (progress: T) => void
61
- ): (progress: T) => void {
62
- return (progress: T) =>
63
- progressCallback({
64
- ...progress,
65
- value: minimum + progress.value * (maximum - minimum),
66
- })
67
- }
@@ -1,20 +0,0 @@
1
- import { IMultiCommitOperationProgress } from './progress.js'
2
- import { CommitOneLine } from './commit.js'
3
-
4
- export type RebaseInternalState = {
5
- readonly targetBranch: string
6
- readonly baseBranchTip: string
7
- readonly originalBranchTip: string
8
- }
9
-
10
- export type RebaseProgressOptions = {
11
- commits: ReadonlyArray<CommitOneLine>
12
- progressCallback: (progress: IMultiCommitOperationProgress) => void
13
- }
14
-
15
- export enum ComputedAction {
16
- Clean = 'Clean',
17
- Conflicts = 'Conflicts',
18
- Invalid = 'Invalid',
19
- Loading = 'Loading',
20
- }
@@ -1,10 +0,0 @@
1
- export interface IRemote {
2
- readonly name: string
3
- readonly url: string
4
- }
5
-
6
- export function remoteEquals(x: IRemote | null, y: IRemote | null) {
7
- if (x === y) return true
8
- if (x === null || y === null) return false
9
- return x.name === y.name && x.url === y.url
10
- }
@@ -1,16 +0,0 @@
1
- import * as Path from 'path'
2
-
3
- export class Repository {
4
- public readonly name: string
5
-
6
- public constructor(
7
- public readonly path: string,
8
- public readonly id: number
9
- ) {
10
- this.name = Path.basename(path)
11
- }
12
-
13
- public get resolvedGitDir(): string {
14
- return Path.join(this.path, '.git')
15
- }
16
- }
@@ -1,25 +0,0 @@
1
- import { CommittedFileChange } from './status.js'
2
-
3
- export interface IStashEntry {
4
- readonly name: string
5
- readonly branchName: string
6
- readonly stashSha: string
7
- readonly files: StashedFileChanges
8
- readonly tree: string
9
- readonly parents: ReadonlyArray<string>
10
- }
11
-
12
- export enum StashedChangesLoadStates {
13
- NotLoaded = 'NotLoaded',
14
- Loading = 'Loading',
15
- Loaded = 'Loaded',
16
- }
17
-
18
- export type StashedFileChanges =
19
- | {
20
- readonly kind: StashedChangesLoadStates.NotLoaded | StashedChangesLoadStates.Loading
21
- }
22
- | {
23
- readonly kind: StashedChangesLoadStates.Loaded
24
- readonly files: ReadonlyArray<CommittedFileChange>
25
- }