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
package/src/git/credential.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { exec as git } from './exec.js'
|
|
2
|
-
|
|
3
|
-
export const parseCredential = (value: string) => {
|
|
4
|
-
const cred = new Map<string, string>()
|
|
5
|
-
|
|
6
|
-
// The credential helper protocol is a simple key=value format but some of its
|
|
7
|
-
// keys are actually arrays which are represented as multiple key[] entries.
|
|
8
|
-
// Since we're currently storing credentials as a Map we need to handle this
|
|
9
|
-
// and expand multiple key[] entries into a key[0], key[1]... key[n] sequence.
|
|
10
|
-
// We then remove the number from the key when we're formatting the credential
|
|
11
|
-
for (const line of value.split(/\r?\n/)) {
|
|
12
|
-
const eqIx = line.indexOf('=')
|
|
13
|
-
if (eqIx === -1) {
|
|
14
|
-
continue
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const k = line.slice(0, eqIx)
|
|
18
|
-
const v = line.slice(eqIx + 1)
|
|
19
|
-
|
|
20
|
-
if (k.endsWith('[]')) {
|
|
21
|
-
let i = 0
|
|
22
|
-
let newKey
|
|
23
|
-
|
|
24
|
-
do {
|
|
25
|
-
newKey = `${k.slice(0, -2)}[${i}]`
|
|
26
|
-
i++
|
|
27
|
-
} while (cred.has(newKey))
|
|
28
|
-
|
|
29
|
-
cred.set(newKey, v)
|
|
30
|
-
} else {
|
|
31
|
-
cred.set(k, v)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return cred
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const formatCredential = (credential: Map<string, string>) => {
|
|
39
|
-
const lines = []
|
|
40
|
-
for (const [k, v] of credential) {
|
|
41
|
-
if (v.includes('\n') || v.includes('\0')) {
|
|
42
|
-
throw new Error(`forbidden characters in credential value: ${k}`)
|
|
43
|
-
}
|
|
44
|
-
lines.push(`${k.replace(/\[\d+\]$/, '[]')}=${v}\n`)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return lines.join('')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Can't use git() as that will call withTrampolineEnv which calls this method
|
|
51
|
-
const exec = (
|
|
52
|
-
cmd: string,
|
|
53
|
-
cred: Map<string, string>,
|
|
54
|
-
path: string,
|
|
55
|
-
env: Record<string, string | undefined> = {}
|
|
56
|
-
) =>
|
|
57
|
-
git(
|
|
58
|
-
[
|
|
59
|
-
...['-c', 'credential.helper='],
|
|
60
|
-
...['-c', `credential.helper=manager`],
|
|
61
|
-
'credential',
|
|
62
|
-
cmd,
|
|
63
|
-
],
|
|
64
|
-
path,
|
|
65
|
-
{
|
|
66
|
-
stdin: formatCredential(cred),
|
|
67
|
-
env: {
|
|
68
|
-
GIT_TERMINAL_PROMPT: '0',
|
|
69
|
-
GIT_ASKPASS: '',
|
|
70
|
-
TERM: 'dumb',
|
|
71
|
-
...env,
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
).then(({ exitCode, stderr, stdout }: any) => {
|
|
75
|
-
if (exitCode !== 0) {
|
|
76
|
-
throw new Error(String(stderr))
|
|
77
|
-
}
|
|
78
|
-
return parseCredential(String(stdout))
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
export const fillCredential = exec.bind(null, 'fill')
|
|
82
|
-
export const approveCredential = exec.bind(null, 'approve')
|
|
83
|
-
export const rejectCredential = exec.bind(null, 'reject')
|
package/src/git/description.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as Path from 'path'
|
|
2
|
-
import { readFile, writeFile } from 'fs/promises'
|
|
3
|
-
|
|
4
|
-
const GitDescriptionPath = '.git/description'
|
|
5
|
-
|
|
6
|
-
export const DefaultGitDescription =
|
|
7
|
-
"Unnamed repository; edit this file 'description' to name the repository.\n"
|
|
8
|
-
|
|
9
|
-
/** Get the repository's description from the .git/description file. */
|
|
10
|
-
export async function getGitDescription(
|
|
11
|
-
repositoryPath: string
|
|
12
|
-
): Promise<string> {
|
|
13
|
-
const path = Path.join(repositoryPath, GitDescriptionPath)
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const data = await readFile(path, 'utf8')
|
|
17
|
-
if (data === DefaultGitDescription) {
|
|
18
|
-
return ''
|
|
19
|
-
}
|
|
20
|
-
return data
|
|
21
|
-
} catch (err) {
|
|
22
|
-
return ''
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Write a .git/description file to the repository. */
|
|
27
|
-
export async function writeGitDescription(
|
|
28
|
-
repositoryPath: string,
|
|
29
|
-
description: string
|
|
30
|
-
): Promise<void> {
|
|
31
|
-
const fullPath = Path.join(repositoryPath, GitDescriptionPath)
|
|
32
|
-
await writeFile(fullPath, description)
|
|
33
|
-
}
|
package/src/git/diff-check.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { git } from './core.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns a list of files with conflict markers present
|
|
5
|
-
*
|
|
6
|
-
* @param repositoryPath filepath to repository
|
|
7
|
-
* @returns filepaths with their number of conflicted markers
|
|
8
|
-
*/
|
|
9
|
-
export async function getFilesWithConflictMarkers(
|
|
10
|
-
repositoryPath: string
|
|
11
|
-
): Promise<Map<string, number>> {
|
|
12
|
-
const { stdout } = await git(
|
|
13
|
-
['diff', '--check'],
|
|
14
|
-
repositoryPath,
|
|
15
|
-
'getFilesWithConflictMarkers',
|
|
16
|
-
{ successExitCodes: new Set([0, 2]) }
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
const files = new Map<string, number>()
|
|
20
|
-
const matches = stdout.matchAll(/^(.+):\d+: leftover conflict marker/gm)
|
|
21
|
-
|
|
22
|
-
for (const [, path] of matches) {
|
|
23
|
-
files.set(path, (files.get(path) ?? 0) + 1)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return files
|
|
27
|
-
}
|
package/src/git/diff-index.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { git } from './core.js'
|
|
2
|
-
import { Repository } from '../models/repository.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Possible statuses of an entry in Git, see the git diff-index
|
|
6
|
-
* man page for additional details.
|
|
7
|
-
*/
|
|
8
|
-
export enum IndexStatus {
|
|
9
|
-
Unknown = 0,
|
|
10
|
-
Added,
|
|
11
|
-
Copied,
|
|
12
|
-
Deleted,
|
|
13
|
-
Modified,
|
|
14
|
-
Renamed,
|
|
15
|
-
TypeChanged,
|
|
16
|
-
Unmerged,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Index statuses excluding renames and copies.
|
|
21
|
-
*
|
|
22
|
-
* Used when invoking diff-index with rename detection explicitly turned
|
|
23
|
-
* off.
|
|
24
|
-
*/
|
|
25
|
-
export type NoRenameIndexStatus =
|
|
26
|
-
| IndexStatus.Added
|
|
27
|
-
| IndexStatus.Deleted
|
|
28
|
-
| IndexStatus.Modified
|
|
29
|
-
| IndexStatus.TypeChanged
|
|
30
|
-
| IndexStatus.Unmerged
|
|
31
|
-
| IndexStatus.Unknown
|
|
32
|
-
|
|
33
|
-
function getIndexStatus(status: string) {
|
|
34
|
-
switch (status[0]) {
|
|
35
|
-
case 'A':
|
|
36
|
-
return IndexStatus.Added
|
|
37
|
-
case 'C':
|
|
38
|
-
return IndexStatus.Copied
|
|
39
|
-
case 'D':
|
|
40
|
-
return IndexStatus.Deleted
|
|
41
|
-
case 'M':
|
|
42
|
-
return IndexStatus.Modified
|
|
43
|
-
case 'R':
|
|
44
|
-
return IndexStatus.Renamed
|
|
45
|
-
case 'T':
|
|
46
|
-
return IndexStatus.TypeChanged
|
|
47
|
-
case 'U':
|
|
48
|
-
return IndexStatus.Unmerged
|
|
49
|
-
case 'X':
|
|
50
|
-
return IndexStatus.Unknown
|
|
51
|
-
default:
|
|
52
|
-
throw new Error(`Unknown index status: ${status}`)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getNoRenameIndexStatus(status: string): NoRenameIndexStatus {
|
|
57
|
-
const parsed = getIndexStatus(status)
|
|
58
|
-
|
|
59
|
-
switch (parsed) {
|
|
60
|
-
case IndexStatus.Copied:
|
|
61
|
-
case IndexStatus.Renamed:
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Invalid index status for no-rename index status: ${parsed}`
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return parsed
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** The SHA for the null tree. */
|
|
71
|
-
export const NullTreeSHA = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get a list of files which have recorded changes in the index as compared to
|
|
75
|
-
* HEAD along with the type of change.
|
|
76
|
-
*
|
|
77
|
-
* @param repository The repository for which to retrieve the index changes.
|
|
78
|
-
*/
|
|
79
|
-
export async function getIndexChanges(
|
|
80
|
-
repository: Repository
|
|
81
|
-
): Promise<Map<string, NoRenameIndexStatus>> {
|
|
82
|
-
const args = ['diff-index', '--cached', '--name-status', '--no-renames', '-z']
|
|
83
|
-
|
|
84
|
-
let result = await git(
|
|
85
|
-
[...args, 'HEAD', '--'],
|
|
86
|
-
repository.path,
|
|
87
|
-
'getIndexChanges',
|
|
88
|
-
{
|
|
89
|
-
successExitCodes: new Set([0, 128]),
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
// 128 from diff-index either means that the path isn't a repository or (more
|
|
94
|
-
// likely) that the repository HEAD is unborn. If HEAD is unborn we'll diff
|
|
95
|
-
// the index against the null tree instead.
|
|
96
|
-
if (result.exitCode === 128) {
|
|
97
|
-
result = await git(
|
|
98
|
-
[...args, NullTreeSHA],
|
|
99
|
-
repository.path,
|
|
100
|
-
'getIndexChanges'
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const map = new Map<string, NoRenameIndexStatus>()
|
|
105
|
-
|
|
106
|
-
const pieces = result.stdout.split('\0')
|
|
107
|
-
|
|
108
|
-
for (let i = 0; i < pieces.length - 1; i += 2) {
|
|
109
|
-
const status = getNoRenameIndexStatus(pieces[i])
|
|
110
|
-
const path = pieces[i + 1]
|
|
111
|
-
|
|
112
|
-
map.set(path, status)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return map
|
|
116
|
-
}
|