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.
- package/README.md +42 -10
- package/dist/git/apply.d.ts +1 -1
- package/dist/git/apply.js +1 -1
- package/dist/git/apply.js.map +1 -1
- package/dist/git/environment.d.ts +1 -1
- package/dist/git/environment.js +1 -1
- package/dist/git/environment.js.map +1 -1
- package/dist/git/exec.js.map +1 -1
- package/dist/git/gitignore.js +1 -1
- package/dist/git/gitignore.js.map +1 -1
- package/dist/git/index.d.ts +1 -0
- package/dist/git/index.js +3 -0
- package/dist/git/index.js.map +1 -1
- package/dist/lib/fatal-error.d.ts +1 -1
- package/dist/lib/fatal-error.js +1 -1
- package/dist/lib/fatal-error.js.map +1 -1
- package/dist/lib/progress/from-process.js.map +1 -1
- package/dist/lib/progress/index.d.ts +5 -5
- package/dist/lib/progress/index.js +5 -5
- package/dist/lib/progress/index.js.map +1 -1
- package/dist/lib/progress/revert.d.ts +1 -1
- package/dist/lib/progress/revert.js +1 -1
- package/dist/lib/progress/revert.js.map +1 -1
- package/dist/lib/status-parser.js +0 -12
- package/dist/lib/status-parser.js.map +1 -1
- package/dist/models/repository.d.ts +1 -1
- package/dist/models/repository.js +1 -1
- package/dist/models/repository.js.map +1 -1
- package/package.json +39 -9
- package/src/git/add.ts +0 -16
- package/src/git/apply.ts +0 -154
- package/src/git/authentication.ts +0 -20
- package/src/git/branch.ts +0 -206
- package/src/git/checkout-index.ts +0 -40
- package/src/git/checkout.ts +0 -235
- package/src/git/cherry-pick.ts +0 -504
- package/src/git/clean.ts +0 -9
- package/src/git/clone.ts +0 -86
- package/src/git/coerce-to-buffer.ts +0 -4
- package/src/git/coerce-to-string.ts +0 -4
- package/src/git/commit.ts +0 -136
- package/src/git/config.ts +0 -392
- package/src/git/core.ts +0 -625
- package/src/git/create-tail-stream.ts +0 -36
- package/src/git/credential.ts +0 -83
- package/src/git/description.ts +0 -33
- package/src/git/diff-check.ts +0 -27
- package/src/git/diff-index.ts +0 -116
- package/src/git/diff.ts +0 -880
- package/src/git/environment.ts +0 -116
- package/src/git/exec.ts +0 -285
- package/src/git/fetch.ts +0 -141
- package/src/git/for-each-ref.ts +0 -160
- package/src/git/format-patch.ts +0 -17
- package/src/git/git-delimiter-parser.ts +0 -95
- package/src/git/gitignore.ts +0 -157
- package/src/git/index.ts +0 -46
- package/src/git/init.ts +0 -11
- package/src/git/interpret-trailers.ts +0 -176
- package/src/git/lfs.ts +0 -100
- package/src/git/log.ts +0 -376
- package/src/git/merge-tree.ts +0 -42
- package/src/git/merge.ts +0 -154
- package/src/git/multi-operation-terminal-output.ts +0 -68
- package/src/git/pull.ts +0 -130
- package/src/git/push-terminal-chunk.ts +0 -41
- package/src/git/push.ts +0 -119
- package/src/git/rebase.ts +0 -627
- package/src/git/reflog.ts +0 -127
- package/src/git/refs.ts +0 -63
- package/src/git/remote.ts +0 -143
- package/src/git/reorder.ts +0 -153
- package/src/git/reset.ts +0 -101
- package/src/git/rev-list.ts +0 -201
- package/src/git/rev-parse.ts +0 -92
- package/src/git/revert.ts +0 -55
- package/src/git/rm.ts +0 -31
- package/src/git/show.ts +0 -88
- package/src/git/spawn.ts +0 -38
- package/src/git/squash.ts +0 -173
- package/src/git/stage.ts +0 -97
- package/src/git/stash.ts +0 -302
- package/src/git/status.ts +0 -502
- package/src/git/submodule.ts +0 -212
- package/src/git/tag.ts +0 -134
- package/src/git/update-index.ts +0 -169
- package/src/git/update-ref.ts +0 -50
- package/src/git/var.ts +0 -42
- package/src/git/worktree-include.ts +0 -146
- package/src/git/worktree.ts +0 -219
- package/src/index.ts +0 -11
- package/src/lib/api.ts +0 -7
- package/src/lib/diff-parser.ts +0 -249
- package/src/lib/directory-exists.ts +0 -10
- package/src/lib/errno-exception.ts +0 -12
- package/src/lib/fatal-error.ts +0 -23
- package/src/lib/feature-flag.ts +0 -29
- package/src/lib/file-system.ts +0 -7
- package/src/lib/get-old-path.ts +0 -11
- package/src/lib/git/environment.ts +0 -14
- package/src/lib/git-perf.ts +0 -3
- package/src/lib/helpers/default-branch.ts +0 -3
- package/src/lib/helpers/path.ts +0 -5
- package/src/lib/hooks/with-hooks-env.ts +0 -7
- package/src/lib/merge.ts +0 -3
- package/src/lib/noop.ts +0 -1
- package/src/lib/patch-formatter.ts +0 -18
- package/src/lib/path-exists.ts +0 -7
- package/src/lib/progress/from-process.ts +0 -10
- package/src/lib/progress/index.ts +0 -43
- package/src/lib/progress/revert.ts +0 -17
- package/src/lib/rebase.ts +0 -3
- package/src/lib/remove-remote-prefix.ts +0 -4
- package/src/lib/resolve-git-proxy.ts +0 -3
- package/src/lib/round.ts +0 -4
- package/src/lib/split-buffer.ts +0 -14
- package/src/lib/status-parser.ts +0 -188
- package/src/lib/stores/helpers/find-default-remote.ts +0 -3
- package/src/lib/trampoline/trampoline-environment.ts +0 -8
- package/src/models/branch.ts +0 -78
- package/src/models/cherry-pick.ts +0 -12
- package/src/models/clone-options.ts +0 -6
- package/src/models/commit-identity.ts +0 -35
- package/src/models/commit.ts +0 -44
- package/src/models/computed-action.ts +0 -6
- package/src/models/diff/diff-data.ts +0 -78
- package/src/models/diff/diff-line.ts +0 -36
- package/src/models/diff/diff-selection.ts +0 -165
- package/src/models/diff/image-diff.ts +0 -6
- package/src/models/diff/image.ts +0 -8
- package/src/models/diff/index.ts +0 -6
- package/src/models/diff/raw-diff.ts +0 -41
- package/src/models/git-author.ts +0 -16
- package/src/models/index.ts +0 -36
- package/src/models/manual-conflict-resolution.ts +0 -4
- package/src/models/merge.ts +0 -6
- package/src/models/multi-commit-operation.ts +0 -6
- package/src/models/progress.ts +0 -67
- package/src/models/rebase.ts +0 -20
- package/src/models/remote.ts +0 -10
- package/src/models/repository.ts +0 -16
- package/src/models/stash-entry.ts +0 -25
- package/src/models/status.ts +0 -275
- package/src/models/submodule.ts +0 -13
- package/src/models/worktree.ts +0 -11
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export { executionOptionsWithProgress } from './from-process.js'
|
|
2
|
-
|
|
3
|
-
export interface IGitOutput {
|
|
4
|
-
kind: string
|
|
5
|
-
text?: string
|
|
6
|
-
percent: number
|
|
7
|
-
details?: { text: string }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class CheckoutProgressParser {
|
|
11
|
-
public parse(line: string): any { return null }
|
|
12
|
-
get percent(): number { return 0 }
|
|
13
|
-
get details(): { text: string } { return { text: '' } }
|
|
14
|
-
get kind(): string { return 'progress' }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class FetchProgressParser {
|
|
18
|
-
public parse(line: string): any { return null }
|
|
19
|
-
get percent(): number { return 0 }
|
|
20
|
-
get details(): { text: string } { return { text: '' } }
|
|
21
|
-
get kind(): string { return 'progress' }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class PullProgressParser {
|
|
25
|
-
public parse(line: string): any { return null }
|
|
26
|
-
get percent(): number { return 0 }
|
|
27
|
-
get details(): { text: string } { return { text: '' } }
|
|
28
|
-
get kind(): string { return 'progress' }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class PushProgressParser {
|
|
32
|
-
public parse(line: string): any { return null }
|
|
33
|
-
get percent(): number { return 0 }
|
|
34
|
-
get details(): { text: string } { return { text: '' } }
|
|
35
|
-
get kind(): string { return 'progress' }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class CloneProgressParser {
|
|
39
|
-
public parse(line: string): any { return null }
|
|
40
|
-
get percent(): number { return 0 }
|
|
41
|
-
get details(): { text: string } { return { text: '' } }
|
|
42
|
-
get kind(): string { return 'progress' }
|
|
43
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export class RevertProgressParser {
|
|
2
|
-
public parse(line: string): any {
|
|
3
|
-
return null
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
public get percent(): number {
|
|
7
|
-
return 0
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
public get details(): { text: string } {
|
|
11
|
-
return { text: '' }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public get kind(): string {
|
|
15
|
-
return 'progress'
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/lib/rebase.ts
DELETED
package/src/lib/round.ts
DELETED
package/src/lib/split-buffer.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function splitBuffer(buffer: Buffer, delimiter: string): Buffer[] {
|
|
2
|
-
const result: Buffer[] = []
|
|
3
|
-
let start = 0
|
|
4
|
-
let index = buffer.indexOf(delimiter, start)
|
|
5
|
-
while (index !== -1) {
|
|
6
|
-
result.push(buffer.subarray(start, index))
|
|
7
|
-
start = index + delimiter.length
|
|
8
|
-
index = buffer.indexOf(delimiter, start)
|
|
9
|
-
}
|
|
10
|
-
if (start <= buffer.length) {
|
|
11
|
-
result.push(buffer.subarray(start))
|
|
12
|
-
}
|
|
13
|
-
return result
|
|
14
|
-
}
|
package/src/lib/status-parser.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FileEntry,
|
|
3
|
-
GitStatusEntry,
|
|
4
|
-
SubmoduleStatus,
|
|
5
|
-
UnmergedEntrySummary,
|
|
6
|
-
} from '../models/status.js'
|
|
7
|
-
import { splitBuffer } from './split-buffer.js'
|
|
8
|
-
|
|
9
|
-
type StatusItem = IStatusHeader | IStatusEntry
|
|
10
|
-
|
|
11
|
-
export interface IStatusHeader {
|
|
12
|
-
readonly kind: 'header'
|
|
13
|
-
readonly value: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IStatusEntry {
|
|
17
|
-
readonly kind: 'entry'
|
|
18
|
-
readonly path: string
|
|
19
|
-
readonly statusCode: string
|
|
20
|
-
readonly submoduleStatusCode: string
|
|
21
|
-
readonly oldPath?: string
|
|
22
|
-
readonly renameOrCopyScore?: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isStatusHeader(
|
|
26
|
-
statusItem: StatusItem
|
|
27
|
-
): statusItem is IStatusHeader {
|
|
28
|
-
return statusItem.kind === 'header'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function isStatusEntry(
|
|
32
|
-
statusItem: StatusItem
|
|
33
|
-
): statusItem is IStatusEntry {
|
|
34
|
-
return statusItem.kind === 'entry'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const ChangedEntryType = '1'
|
|
38
|
-
const RenamedOrCopiedEntryType = '2'
|
|
39
|
-
const UnmergedEntryType = 'u'
|
|
40
|
-
const UntrackedEntryType = '?'
|
|
41
|
-
|
|
42
|
-
const changedEntryRe =
|
|
43
|
-
/^1 ([MADRCUTX?!.]{2}) (N\.\.\.|S[C.][M.][U.]) (\d+) (\d+) (\d+) ([a-f0-9]+) ([a-f0-9]+) ([\s\S]*?)$/
|
|
44
|
-
|
|
45
|
-
const renamedOrCopiedEntryRe =
|
|
46
|
-
/^2 ([MADRCUTX?!.]{2}) (N\.\.\.|S[C.][M.][U.]) (\d+) (\d+) (\d+) ([a-f0-9]+) ([a-f0-9]+) ([RC]\d+) ([\s\S]*?)$/
|
|
47
|
-
|
|
48
|
-
const unmergedEntryRe =
|
|
49
|
-
/^u ([DAU]{2}) (N\.\.\.|S[C.][M.][U.]) (\d+) (\d+) (\d+) (\d+) ([a-f0-9]+) ([a-f0-9]+) ([a-f0-9]+) ([\s\S]*?)$/
|
|
50
|
-
|
|
51
|
-
export function parsePorcelainStatus(
|
|
52
|
-
output: Buffer
|
|
53
|
-
): ReadonlyArray<StatusItem> {
|
|
54
|
-
const entries = new Array<StatusItem>()
|
|
55
|
-
const tokens = splitBuffer(output, '\0')
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
58
|
-
const field = tokens[i].toString()
|
|
59
|
-
if (field.startsWith('# ') && field.length > 2) {
|
|
60
|
-
entries.push({ kind: 'header', value: field.substring(2) })
|
|
61
|
-
continue
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const entryKind = field.substring(0, 1)
|
|
65
|
-
|
|
66
|
-
if (entryKind === ChangedEntryType) {
|
|
67
|
-
entries.push(parseChangedEntry(field))
|
|
68
|
-
} else if (entryKind === RenamedOrCopiedEntryType) {
|
|
69
|
-
entries.push(parsedRenamedOrCopiedEntry(field, tokens[++i].toString()))
|
|
70
|
-
} else if (entryKind === UnmergedEntryType) {
|
|
71
|
-
entries.push(parseUnmergedEntry(field))
|
|
72
|
-
} else if (entryKind === UntrackedEntryType) {
|
|
73
|
-
entries.push(parseUntrackedEntry(field))
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return entries
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function parseChangedEntry(field: string): IStatusEntry {
|
|
81
|
-
const match = changedEntryRe.exec(field)
|
|
82
|
-
if (!match) throw new Error(`Failed to parse status line for changed entry`)
|
|
83
|
-
return {
|
|
84
|
-
kind: 'entry',
|
|
85
|
-
statusCode: match[1],
|
|
86
|
-
submoduleStatusCode: match[2],
|
|
87
|
-
path: match[8],
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function parsedRenamedOrCopiedEntry(
|
|
92
|
-
field: string,
|
|
93
|
-
oldPath: string | undefined
|
|
94
|
-
): IStatusEntry {
|
|
95
|
-
const match = renamedOrCopiedEntryRe.exec(field)
|
|
96
|
-
if (!match) throw new Error(`Failed to parse status line for renamed or copied entry`)
|
|
97
|
-
if (!oldPath) throw new Error('Failed to parse renamed or copied entry, could not parse old path')
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
kind: 'entry',
|
|
101
|
-
statusCode: match[1],
|
|
102
|
-
submoduleStatusCode: match[2],
|
|
103
|
-
oldPath,
|
|
104
|
-
renameOrCopyScore: parseInt(match[8].substring(1), 10),
|
|
105
|
-
path: match[9],
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function parseUnmergedEntry(field: string): IStatusEntry {
|
|
110
|
-
const match = unmergedEntryRe.exec(field)
|
|
111
|
-
if (!match) throw new Error(`Failed to parse status line for unmerged entry`)
|
|
112
|
-
return {
|
|
113
|
-
kind: 'entry',
|
|
114
|
-
statusCode: match[1],
|
|
115
|
-
submoduleStatusCode: match[2],
|
|
116
|
-
path: match[10],
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function parseUntrackedEntry(field: string): IStatusEntry {
|
|
121
|
-
const path = field.substring(2)
|
|
122
|
-
return {
|
|
123
|
-
kind: 'entry',
|
|
124
|
-
statusCode: '??',
|
|
125
|
-
submoduleStatusCode: '????',
|
|
126
|
-
path,
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function mapSubmoduleStatus(
|
|
131
|
-
submoduleStatusCode: string
|
|
132
|
-
): SubmoduleStatus | undefined {
|
|
133
|
-
if (!submoduleStatusCode.startsWith('S')) return undefined
|
|
134
|
-
return {
|
|
135
|
-
commitChanged: submoduleStatusCode[1] === 'C',
|
|
136
|
-
modifiedChanges: submoduleStatusCode[2] === 'M',
|
|
137
|
-
untrackedChanges: submoduleStatusCode[3] === 'U',
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function mapStatus(
|
|
142
|
-
statusCode: string,
|
|
143
|
-
submoduleStatusCode: string,
|
|
144
|
-
renameOrCopyScore: number | undefined
|
|
145
|
-
): FileEntry {
|
|
146
|
-
const submoduleStatus = mapSubmoduleStatus(submoduleStatusCode)
|
|
147
|
-
|
|
148
|
-
if (statusCode === '??') return { kind: 'untracked', submoduleStatus }
|
|
149
|
-
|
|
150
|
-
const sc = (code: string, idx: 'index' | 'workingTree') => {
|
|
151
|
-
const map: Record<string, GitStatusEntry> = {
|
|
152
|
-
'M': GitStatusEntry.Modified,
|
|
153
|
-
'A': GitStatusEntry.Added,
|
|
154
|
-
'D': GitStatusEntry.Deleted,
|
|
155
|
-
'R': GitStatusEntry.Renamed,
|
|
156
|
-
'C': GitStatusEntry.Copied,
|
|
157
|
-
'.': GitStatusEntry.Unchanged,
|
|
158
|
-
'U': GitStatusEntry.UpdatedButUnmerged,
|
|
159
|
-
}
|
|
160
|
-
return map[code] ?? GitStatusEntry.Modified
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const pairs: Record<string, () => FileEntry> = {
|
|
164
|
-
'.M': () => ({ kind: 'ordinary', type: 'modified', index: GitStatusEntry.Unchanged, workingTree: GitStatusEntry.Modified, submoduleStatus }),
|
|
165
|
-
'M.': () => ({ kind: 'ordinary', type: 'modified', index: GitStatusEntry.Modified, workingTree: GitStatusEntry.Unchanged, submoduleStatus }),
|
|
166
|
-
'.A': () => ({ kind: 'ordinary', type: 'added', index: GitStatusEntry.Unchanged, workingTree: GitStatusEntry.Added, submoduleStatus }),
|
|
167
|
-
'A.': () => ({ kind: 'ordinary', type: 'added', index: GitStatusEntry.Added, workingTree: GitStatusEntry.Unchanged, submoduleStatus }),
|
|
168
|
-
'.D': () => ({ kind: 'ordinary', type: 'deleted', index: GitStatusEntry.Unchanged, workingTree: GitStatusEntry.Deleted, submoduleStatus }),
|
|
169
|
-
'D.': () => ({ kind: 'ordinary', type: 'deleted', index: GitStatusEntry.Deleted, workingTree: GitStatusEntry.Unchanged, submoduleStatus }),
|
|
170
|
-
'R.': () => ({ kind: 'renamed' as const, index: GitStatusEntry.Renamed, workingTree: GitStatusEntry.Unchanged, renameOrCopyScore, submoduleStatus }),
|
|
171
|
-
'.R': () => ({ kind: 'renamed' as const, index: GitStatusEntry.Unchanged, workingTree: GitStatusEntry.Renamed, renameOrCopyScore, submoduleStatus }),
|
|
172
|
-
'C.': () => ({ kind: 'copied' as const, index: GitStatusEntry.Copied, workingTree: GitStatusEntry.Unchanged, submoduleStatus }),
|
|
173
|
-
'.C': () => ({ kind: 'copied' as const, index: GitStatusEntry.Unchanged, workingTree: GitStatusEntry.Copied, submoduleStatus }),
|
|
174
|
-
'AD': () => ({ kind: 'ordinary', type: 'added', index: GitStatusEntry.Added, workingTree: GitStatusEntry.Deleted, submoduleStatus }),
|
|
175
|
-
'AM': () => ({ kind: 'ordinary', type: 'added', index: GitStatusEntry.Added, workingTree: GitStatusEntry.Modified, submoduleStatus }),
|
|
176
|
-
'RM': () => ({ kind: 'renamed' as const, index: GitStatusEntry.Renamed, workingTree: GitStatusEntry.Modified, renameOrCopyScore, submoduleStatus }),
|
|
177
|
-
'RD': () => ({ kind: 'renamed' as const, index: GitStatusEntry.Renamed, workingTree: GitStatusEntry.Deleted, renameOrCopyScore, submoduleStatus }),
|
|
178
|
-
'DD': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.BothDeleted, us: GitStatusEntry.Deleted, them: GitStatusEntry.Deleted, submoduleStatus }),
|
|
179
|
-
'AU': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.AddedByUs, us: GitStatusEntry.Added, them: GitStatusEntry.UpdatedButUnmerged, submoduleStatus }),
|
|
180
|
-
'UD': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.DeletedByThem, us: GitStatusEntry.UpdatedButUnmerged, them: GitStatusEntry.Deleted, submoduleStatus }),
|
|
181
|
-
'UA': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.AddedByThem, us: GitStatusEntry.UpdatedButUnmerged, them: GitStatusEntry.Added, submoduleStatus }),
|
|
182
|
-
'DU': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.DeletedByUs, us: GitStatusEntry.Deleted, them: GitStatusEntry.UpdatedButUnmerged, submoduleStatus }),
|
|
183
|
-
'AA': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.BothAdded, us: GitStatusEntry.Added, them: GitStatusEntry.Added, submoduleStatus }),
|
|
184
|
-
'UU': () => ({ kind: 'conflicted' as const, action: UnmergedEntrySummary.BothModified, us: GitStatusEntry.UpdatedButUnmerged, them: GitStatusEntry.UpdatedButUnmerged, submoduleStatus }),
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return pairs[statusCode]?.() ?? { kind: 'ordinary', type: 'modified', submoduleStatus }
|
|
188
|
-
}
|
package/src/models/branch.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export enum BranchType {
|
|
2
|
-
Local = 0,
|
|
3
|
-
Remote = 1,
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface IAheadBehind {
|
|
7
|
-
readonly ahead: number
|
|
8
|
-
readonly behind: number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ICompareResult extends IAheadBehind {
|
|
12
|
-
readonly commits: ReadonlyArray<Commit>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ITrackingBranch {
|
|
16
|
-
readonly ref: string
|
|
17
|
-
readonly sha: string
|
|
18
|
-
readonly upstreamRef: string
|
|
19
|
-
readonly upstreamSha: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface IAuthor {
|
|
23
|
-
readonly date: Date
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface IBranchTip {
|
|
27
|
-
readonly sha: string
|
|
28
|
-
readonly author: IAuthor
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export enum StartPoint {
|
|
32
|
-
CurrentBranch = 'CurrentBranch',
|
|
33
|
-
DefaultBranch = 'DefaultBranch',
|
|
34
|
-
Head = 'Head',
|
|
35
|
-
UpstreamDefaultBranch = 'UpstreamDefaultBranch',
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export class Branch {
|
|
39
|
-
public constructor(
|
|
40
|
-
public readonly name: string,
|
|
41
|
-
public readonly upstream: string | null,
|
|
42
|
-
public readonly tip: IBranchTip,
|
|
43
|
-
public readonly type: BranchType,
|
|
44
|
-
public readonly ref: string,
|
|
45
|
-
public readonly isGone: boolean
|
|
46
|
-
) {}
|
|
47
|
-
|
|
48
|
-
public get upstreamRemoteName(): string | null {
|
|
49
|
-
const upstream = this.upstream
|
|
50
|
-
if (!upstream) return null
|
|
51
|
-
const pieces = upstream.match(/(.*?)\/.*/)
|
|
52
|
-
if (!pieces || pieces.length < 2) return null
|
|
53
|
-
return pieces[1]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public get remoteName(): string | null {
|
|
57
|
-
if (this.type === BranchType.Local) return null
|
|
58
|
-
const pieces = this.ref.match(/^refs\/remotes\/(.*?)\/.*/)
|
|
59
|
-
if (!pieces || pieces.length !== 2) {
|
|
60
|
-
throw new Error(`Remote branch ref has unexpected format: ${this.ref}`)
|
|
61
|
-
}
|
|
62
|
-
return pieces[1]
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public get upstreamWithoutRemote(): string | null {
|
|
66
|
-
if (!this.upstream) return null
|
|
67
|
-
const pieces = this.upstream.match(/^[^/]+\/(.*)/)
|
|
68
|
-
return pieces ? pieces[1] : null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public get nameWithoutRemote(): string {
|
|
72
|
-
if (this.type === BranchType.Local) return this.name
|
|
73
|
-
const pieces = this.name.match(/^[^/]+\/(.*)/)
|
|
74
|
-
return pieces ? pieces[1] : this.name
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
import { Commit } from './commit.js'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IMultiCommitOperationProgress } from './progress.js'
|
|
2
|
-
import { CommitOneLine } from './commit.js'
|
|
3
|
-
|
|
4
|
-
export interface ICherryPickSnapshot {
|
|
5
|
-
readonly sha: string
|
|
6
|
-
readonly parentCount: number
|
|
7
|
-
readonly progress: IMultiCommitOperationProgress | null
|
|
8
|
-
readonly commits: ReadonlyArray<CommitOneLine>
|
|
9
|
-
readonly remainingCommits: ReadonlyArray<CommitOneLine>
|
|
10
|
-
readonly targetBranchUndoSha: string
|
|
11
|
-
readonly cherryPickedCount: number
|
|
12
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export class CommitIdentity {
|
|
2
|
-
public static parseIdentity(identity: string): CommitIdentity {
|
|
3
|
-
const m = identity.match(/^(.*?) <(.*?)> (\d+) (\+|-)?(\d{2})(\d{2})/)
|
|
4
|
-
if (!m) {
|
|
5
|
-
throw new Error(`Couldn't parse identity ${identity}`)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const name = m[1]
|
|
9
|
-
const email = m[2]
|
|
10
|
-
const date = new Date(parseInt(m[3], 10) * 1000)
|
|
11
|
-
|
|
12
|
-
if (isNaN(date.valueOf())) {
|
|
13
|
-
throw new Error(`Couldn't parse identity ${identity}, invalid date`)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const tzSign = m[4] === '-' ? '-' : '+'
|
|
17
|
-
const tzHH = m[5]
|
|
18
|
-
const tzmm = m[6]
|
|
19
|
-
const tzMinutes = parseInt(tzHH, 10) * 60 + parseInt(tzmm, 10)
|
|
20
|
-
const tzOffset = tzMinutes * (tzSign === '-' ? -1 : 1)
|
|
21
|
-
|
|
22
|
-
return new CommitIdentity(name, email, date, tzOffset)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public constructor(
|
|
26
|
-
public readonly name: string,
|
|
27
|
-
public readonly email: string,
|
|
28
|
-
public readonly date: Date,
|
|
29
|
-
public readonly tzOffset: number = new Date().getTimezoneOffset()
|
|
30
|
-
) {}
|
|
31
|
-
|
|
32
|
-
public toString() {
|
|
33
|
-
return `${this.name} <${this.email}>`
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/models/commit.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export function shortenSHA(sha: string) {
|
|
2
|
-
return sha.slice(0, 7)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface ICommitContext {
|
|
6
|
-
readonly summary: string
|
|
7
|
-
readonly description: string | null
|
|
8
|
-
readonly amend?: boolean
|
|
9
|
-
readonly trailers?: ReadonlyArray<ITrailer>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type CommitOneLine = {
|
|
13
|
-
readonly sha: string
|
|
14
|
-
readonly summary: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ITrailer {
|
|
18
|
-
readonly token: string
|
|
19
|
-
readonly value: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class Commit {
|
|
23
|
-
public readonly authoredByCommitter: boolean
|
|
24
|
-
public readonly isMergeCommit: boolean
|
|
25
|
-
|
|
26
|
-
public constructor(
|
|
27
|
-
public readonly sha: string,
|
|
28
|
-
public readonly shortSha: string,
|
|
29
|
-
public readonly summary: string,
|
|
30
|
-
public readonly body: string,
|
|
31
|
-
public readonly author: CommitIdentity,
|
|
32
|
-
public readonly committer: CommitIdentity,
|
|
33
|
-
public readonly parentSHAs: ReadonlyArray<string>,
|
|
34
|
-
public readonly trailers: ReadonlyArray<ITrailer>,
|
|
35
|
-
public readonly tags: ReadonlyArray<string>
|
|
36
|
-
) {
|
|
37
|
-
this.authoredByCommitter =
|
|
38
|
-
this.author.name === this.committer.name &&
|
|
39
|
-
this.author.email === this.committer.email
|
|
40
|
-
this.isMergeCommit = parentSHAs.length > 1
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
import { CommitIdentity } from './commit-identity.js'
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { DiffHunk } from './raw-diff.js'
|
|
2
|
-
import { Image } from './image.js'
|
|
3
|
-
import { SubmoduleStatus } from '../status.js'
|
|
4
|
-
|
|
5
|
-
export enum DiffType {
|
|
6
|
-
Text,
|
|
7
|
-
Image,
|
|
8
|
-
Binary,
|
|
9
|
-
Submodule,
|
|
10
|
-
LargeText,
|
|
11
|
-
Unrenderable,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type LineEnding = 'CR' | 'LF' | 'CRLF'
|
|
15
|
-
|
|
16
|
-
export type LineEndingsChange = {
|
|
17
|
-
from: LineEnding
|
|
18
|
-
to: LineEnding
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function parseLineEndingText(text: string): LineEnding | null {
|
|
22
|
-
const input = text.trim()
|
|
23
|
-
switch (input) {
|
|
24
|
-
case 'CR': return 'CR'
|
|
25
|
-
case 'LF': return 'LF'
|
|
26
|
-
case 'CRLF': return 'CRLF'
|
|
27
|
-
default: return null
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface ITextDiffData {
|
|
32
|
-
readonly text: string
|
|
33
|
-
readonly hunks: ReadonlyArray<DiffHunk>
|
|
34
|
-
readonly lineEndingsChange?: LineEndingsChange
|
|
35
|
-
readonly maxLineNumber: number
|
|
36
|
-
readonly hasHiddenBidiChars: boolean
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ITextDiff extends ITextDiffData {
|
|
40
|
-
readonly kind: DiffType.Text
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface IImageDiff {
|
|
44
|
-
readonly kind: DiffType.Image
|
|
45
|
-
readonly previous?: Image
|
|
46
|
-
readonly current?: Image
|
|
47
|
-
readonly textDiff?: ITextDiffData
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface IBinaryDiff {
|
|
51
|
-
readonly kind: DiffType.Binary
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ISubmoduleDiff {
|
|
55
|
-
readonly kind: DiffType.Submodule
|
|
56
|
-
readonly fullPath: string
|
|
57
|
-
readonly path: string
|
|
58
|
-
readonly url: string | null
|
|
59
|
-
readonly status: SubmoduleStatus
|
|
60
|
-
readonly oldSHA: string | null
|
|
61
|
-
readonly newSHA: string | null
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ILargeTextDiff extends ITextDiffData {
|
|
65
|
-
readonly kind: DiffType.LargeText
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface IUnrenderableDiff {
|
|
69
|
-
readonly kind: DiffType.Unrenderable
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type IDiff =
|
|
73
|
-
| ITextDiff
|
|
74
|
-
| IImageDiff
|
|
75
|
-
| IBinaryDiff
|
|
76
|
-
| ISubmoduleDiff
|
|
77
|
-
| ILargeTextDiff
|
|
78
|
-
| IUnrenderableDiff
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export enum DiffLineType {
|
|
2
|
-
Context,
|
|
3
|
-
Add,
|
|
4
|
-
Delete,
|
|
5
|
-
Hunk,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class DiffLine {
|
|
9
|
-
public constructor(
|
|
10
|
-
public readonly text: string,
|
|
11
|
-
public readonly type: DiffLineType,
|
|
12
|
-
public readonly originalLineNumber: number | null,
|
|
13
|
-
public readonly oldLineNumber: number | null,
|
|
14
|
-
public readonly newLineNumber: number | null,
|
|
15
|
-
public readonly noTrailingNewLine: boolean = false
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
public withNoTrailingNewLine(noTrailingNewLine: boolean): DiffLine {
|
|
19
|
-
return new DiffLine(
|
|
20
|
-
this.text,
|
|
21
|
-
this.type,
|
|
22
|
-
this.originalLineNumber,
|
|
23
|
-
this.oldLineNumber,
|
|
24
|
-
this.newLineNumber,
|
|
25
|
-
noTrailingNewLine
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public isIncludeableLine() {
|
|
30
|
-
return this.type === DiffLineType.Add || this.type === DiffLineType.Delete
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public get content(): string {
|
|
34
|
-
return this.text.substring(1)
|
|
35
|
-
}
|
|
36
|
-
}
|