@gitkraken/core-gitlens 0.1.0 → 0.2.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.
- package/CHANGELOG.md +22 -1
- package/dist/git/cache.d.ts +21 -5
- package/dist/git/cache.d.ts.map +1 -1
- package/dist/git/cache.js +102 -6
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +11 -2
- package/dist/git/context.d.ts.map +1 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/models/branch.d.ts +1 -0
- package/dist/git/models/branch.d.ts.map +1 -1
- package/dist/git/models/branch.js.map +1 -1
- package/dist/git/models/commit.d.ts +1 -9
- package/dist/git/models/commit.d.ts.map +1 -1
- package/dist/git/models/commit.js +4 -9
- package/dist/git/models/commit.js.map +1 -1
- package/dist/git/models/graph.d.ts +2 -4
- package/dist/git/models/graph.d.ts.map +1 -1
- package/dist/git/models/repository.d.ts +12 -3
- package/dist/git/models/repository.d.ts.map +1 -1
- package/dist/git/models/repository.js +25 -4
- package/dist/git/models/repository.js.map +1 -1
- package/dist/git/models/worktree.d.ts +1 -1
- package/dist/git/models/worktree.d.ts.map +1 -1
- package/dist/git/models/worktree.js +2 -2
- package/dist/git/models/worktree.js.map +1 -1
- package/dist/git/parsers/diffParser.d.ts +0 -1
- package/dist/git/parsers/diffParser.d.ts.map +1 -1
- package/dist/git/parsers/diffParser.js +22 -61
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/providers/branches.d.ts +3 -0
- package/dist/git/providers/branches.d.ts.map +1 -1
- package/dist/git/providers/commits.d.ts +6 -0
- package/dist/git/providers/commits.d.ts.map +1 -1
- package/dist/git/providers/config.d.ts +2 -0
- package/dist/git/providers/config.d.ts.map +1 -1
- package/dist/git/providers/diff.d.ts +2 -0
- package/dist/git/providers/diff.d.ts.map +1 -1
- package/dist/git/providers/operations.d.ts +6 -0
- package/dist/git/providers/operations.d.ts.map +1 -1
- package/dist/git/providers/revision.d.ts +1 -1
- package/dist/git/providers/revision.d.ts.map +1 -1
- package/dist/git/providers/staging.d.ts +2 -0
- package/dist/git/providers/staging.d.ts.map +1 -1
- package/dist/git/utils/sorting.d.ts +6 -0
- package/dist/git/utils/sorting.d.ts.map +1 -1
- package/dist/git/utils/sorting.js +19 -0
- package/dist/git/utils/sorting.js.map +1 -1
- package/dist/git-cli/cliGitProvider.js +1 -1
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +29 -4
- package/dist/git-cli/exec/git.d.ts.map +1 -1
- package/dist/git-cli/exec/git.js +70 -9
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.d.ts +12 -4
- package/dist/git-cli/exec/gitQueue.d.ts.map +1 -1
- package/dist/git-cli/exec/gitQueue.js +49 -12
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/parsers/logParser.d.ts +1 -0
- package/dist/git-cli/parsers/logParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/logParser.js +4 -0
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/blame.js +1 -1
- package/dist/git-cli/providers/blame.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +2 -0
- package/dist/git-cli/providers/branches.d.ts.map +1 -1
- package/dist/git-cli/providers/branches.js +176 -123
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +4 -0
- package/dist/git-cli/providers/commits.d.ts.map +1 -1
- package/dist/git-cli/providers/commits.js +58 -17
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts.map +1 -1
- package/dist/git-cli/providers/config.js +9 -9
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.d.ts.map +1 -1
- package/dist/git-cli/providers/contributors.js +7 -4
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +2 -0
- package/dist/git-cli/providers/diff.d.ts.map +1 -1
- package/dist/git-cli/providers/diff.js +89 -19
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.d.ts.map +1 -1
- package/dist/git-cli/providers/graph.js +43 -27
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +17 -0
- package/dist/git-cli/providers/operations.d.ts.map +1 -1
- package/dist/git-cli/providers/operations.js +47 -14
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.d.ts.map +1 -1
- package/dist/git-cli/providers/patch.js +15 -30
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +6 -6
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts.map +1 -1
- package/dist/git-cli/providers/refs.js +26 -7
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +4 -4
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +1 -1
- package/dist/git-cli/providers/revision.d.ts.map +1 -1
- package/dist/git-cli/providers/revision.js +15 -11
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +2 -0
- package/dist/git-cli/providers/staging.d.ts.map +1 -1
- package/dist/git-cli/providers/staging.js +20 -8
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/stash.d.ts +0 -8
- package/dist/git-cli/providers/stash.d.ts.map +1 -1
- package/dist/git-cli/providers/stash.js +63 -119
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.js +6 -6
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.js +4 -4
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +3 -3
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/plus/ai/constants.d.ts +2 -1
- package/dist/plus/ai/constants.d.ts.map +1 -1
- package/dist/plus/ai/constants.js +7 -0
- package/dist/plus/ai/constants.js.map +1 -1
- package/dist/plus/ai/models/model.d.ts +1 -1
- package/dist/plus/ai/models/model.d.ts.map +1 -1
- package/dist/plus/ai/models/model.js.map +1 -1
- package/dist/plus/ai/models/promptTemplates.d.ts +19 -2
- package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -1
- package/dist/plus/ai/models/results.d.ts +28 -0
- package/dist/plus/ai/models/results.d.ts.map +1 -1
- package/dist/plus/ai/prompts.d.ts +3 -0
- package/dist/plus/ai/prompts.d.ts.map +1 -1
- package/dist/plus/ai/prompts.js +126 -0
- package/dist/plus/ai/prompts.js.map +1 -1
- package/dist/plus/ai/utils/ai.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/ai.utils.js +2 -0
- package/dist/plus/ai/utils/ai.utils.js.map +1 -1
- package/dist/plus/ai/utils/results.utils.d.ts +3 -0
- package/dist/plus/ai/utils/results.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/results.utils.js +75 -0
- package/dist/plus/ai/utils/results.utils.js.map +1 -1
- package/dist/plus/ai/utils/truncation.utils.d.ts +1 -1
- package/dist/plus/ai/utils/truncation.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/truncation.utils.js.map +1 -1
- package/dist/plus/git-github/providers/github/branches.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/branches.js +16 -1
- package/dist/plus/git-github/providers/github/branches.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +2 -0
- package/dist/plus/git-github/providers/github/diff.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/utils/decorators/log.js +1 -1
- package/dist/utils/decorators/log.js.map +1 -1
- package/dist/utils/decorators/sequentialize.d.ts.map +1 -1
- package/dist/utils/decorators/sequentialize.js +4 -2
- package/dist/utils/decorators/sequentialize.js.map +1 -1
- package/dist/utils/env/node/base64.js.map +1 -1
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +4 -10
- package/dist/utils/formatter.js.map +1 -1
- package/dist/utils/iterable.js.map +1 -1
- package/dist/utils/lruMap.d.ts +40 -0
- package/dist/utils/lruMap.d.ts.map +1 -0
- package/dist/utils/lruMap.js +81 -0
- package/dist/utils/lruMap.js.map +1 -0
- package/dist/utils/version.d.ts +14 -0
- package/dist/utils/version.d.ts.map +1 -1
- package/dist/utils/version.js +48 -0
- package/dist/utils/version.js.map +1 -1
- package/package.json +1 -1
- package/src/git/cache.ts +179 -13
- package/src/git/context.ts +11 -2
- package/src/git/models/branch.ts +1 -0
- package/src/git/models/commit.ts +1 -17
- package/src/git/models/graph.ts +2 -4
- package/src/git/models/repository.ts +26 -6
- package/src/git/models/worktree.ts +2 -2
- package/src/git/parsers/diffParser.ts +7 -44
- package/src/git/providers/branches.ts +3 -0
- package/src/git/providers/commits.ts +7 -0
- package/src/git/providers/config.ts +2 -0
- package/src/git/providers/diff.ts +8 -2
- package/src/git/providers/operations.ts +10 -3
- package/src/git/providers/revision.ts +5 -1
- package/src/git/providers/staging.ts +2 -0
- package/src/git/utils/sorting.ts +21 -0
- package/src/git-cli/cliGitProvider.ts +1 -1
- package/src/git-cli/exec/git.ts +70 -18
- package/src/git-cli/exec/gitQueue.ts +57 -13
- package/src/git-cli/parsers/logParser.ts +5 -1
- package/src/git-cli/providers/blame.ts +1 -1
- package/src/git-cli/providers/branches.ts +207 -133
- package/src/git-cli/providers/commits.ts +71 -18
- package/src/git-cli/providers/config.ts +9 -14
- package/src/git-cli/providers/contributors.ts +7 -12
- package/src/git-cli/providers/diff.ts +100 -19
- package/src/git-cli/providers/graph.ts +47 -27
- package/src/git-cli/providers/operations.ts +77 -18
- package/src/git-cli/providers/patch.ts +15 -37
- package/src/git-cli/providers/pausedOperations.ts +6 -6
- package/src/git-cli/providers/refs.ts +27 -8
- package/src/git-cli/providers/remotes.ts +4 -4
- package/src/git-cli/providers/revision.ts +20 -13
- package/src/git-cli/providers/staging.ts +18 -8
- package/src/git-cli/providers/stash.ts +67 -134
- package/src/git-cli/providers/status.ts +6 -6
- package/src/git-cli/providers/tags.ts +4 -4
- package/src/git-cli/providers/worktrees.ts +3 -3
- package/src/plus/ai/constants.ts +8 -0
- package/src/plus/ai/models/model.ts +1 -0
- package/src/plus/ai/models/promptTemplates.ts +29 -0
- package/src/plus/ai/models/results.ts +30 -0
- package/src/plus/ai/prompts.ts +129 -0
- package/src/plus/ai/utils/ai.utils.ts +2 -0
- package/src/plus/ai/utils/results.utils.ts +99 -0
- package/src/plus/ai/utils/truncation.utils.ts +3 -1
- package/src/plus/git-github/providers/github/branches.ts +17 -5
- package/src/plus/git-github/providers/github/diff.ts +8 -2
- package/src/utils/decorators/log.ts +1 -1
- package/src/utils/decorators/sequentialize.ts +8 -6
- package/src/utils/env/node/base64.ts +1 -1
- package/src/utils/env/node/exec.ts +2 -2
- package/src/utils/formatter.ts +4 -11
- package/src/utils/iterable.ts +1 -1
- package/src/utils/lruMap.ts +87 -0
- package/src/utils/version.ts +48 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded LRU map. On `set` / `update`, the touched key becomes the
|
|
3
|
+
* most-recently-used entry; on overflow, the least-recently-used key is
|
|
4
|
+
* evicted until `size <= limit`. Built on a plain `Map`, exploiting that
|
|
5
|
+
* `Map` preserves insertion order — re-inserting a key moves it to the end.
|
|
6
|
+
*
|
|
7
|
+
* Intentionally minimal — `get` / `set` / `delete` / `clear` / `size` /
|
|
8
|
+
* `has` / `keys` / `values` / `update`. No expiry, no async, no events.
|
|
9
|
+
* Callers that need invalidation rules layer them on top.
|
|
10
|
+
*
|
|
11
|
+
* `update(key, patch)` is a convenience for object-shaped values: merges
|
|
12
|
+
* `patch` into the existing entry (or seeds a new one) and touches the key.
|
|
13
|
+
* Use `set` for non-object values.
|
|
14
|
+
*/
|
|
15
|
+
export class LruMap<K, V> {
|
|
16
|
+
private readonly _map = new Map<K, V>();
|
|
17
|
+
|
|
18
|
+
constructor(private readonly limit: number) {}
|
|
19
|
+
|
|
20
|
+
get size(): number {
|
|
21
|
+
return this._map.size;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get(key: K): V | undefined {
|
|
25
|
+
return this._map.get(key);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
has(key: K): boolean {
|
|
29
|
+
return this._map.has(key);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
set(key: K, value: V): this {
|
|
33
|
+
// Re-insert to move the key to the end (most-recently-used).
|
|
34
|
+
this._map.delete(key);
|
|
35
|
+
this._map.set(key, value);
|
|
36
|
+
this.evict();
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Merge `patch` into the existing entry (or seed a new entry from it) and
|
|
42
|
+
* touch the key. Returns the merged value. Object-shaped `V` only.
|
|
43
|
+
*/
|
|
44
|
+
update(key: K, patch: Partial<V>): V {
|
|
45
|
+
const existing = this._map.get(key);
|
|
46
|
+
const next = { ...(existing ?? {}), ...patch };
|
|
47
|
+
this.set(key, next as V);
|
|
48
|
+
return next as V;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Promote an existing entry to most-recently-used without changing its value.
|
|
53
|
+
* Returns `true` if the key was present (and therefore touched), `false` otherwise.
|
|
54
|
+
* Use on cache hits when you want subsequent eviction pressure to skip this entry.
|
|
55
|
+
*/
|
|
56
|
+
touch(key: K): boolean {
|
|
57
|
+
if (!this._map.has(key)) return false;
|
|
58
|
+
const value = this._map.get(key) as V;
|
|
59
|
+
this._map.delete(key);
|
|
60
|
+
this._map.set(key, value);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
delete(key: K): boolean {
|
|
65
|
+
return this._map.delete(key);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
clear(): void {
|
|
69
|
+
this._map.clear();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
keys(): IterableIterator<K> {
|
|
73
|
+
return this._map.keys();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
values(): IterableIterator<V> {
|
|
77
|
+
return this._map.values();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private evict(): void {
|
|
81
|
+
while (this._map.size > this.limit) {
|
|
82
|
+
const oldest = this._map.keys().next().value;
|
|
83
|
+
if (oldest === undefined) break;
|
|
84
|
+
this._map.delete(oldest);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/utils/version.ts
CHANGED
|
@@ -55,6 +55,54 @@ export function fromVersion(v: Version, includePre?: boolean): `${number}.${numb
|
|
|
55
55
|
return `${v.major}.${v.minor}.${v.patch}${includePre && v.pre ? `-${v.pre}` : ''}`;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Compares two strings using version-aware sorting in descending order,
|
|
60
|
+
* matching git's `--sort=-version:refname` (based on glibc's `strverscmp`).
|
|
61
|
+
*
|
|
62
|
+
* Walks character-by-character: non-digit runs are compared lexicographically,
|
|
63
|
+
* digit runs are compared numerically. No prefix stripping (git only strips
|
|
64
|
+
* prefixes when `versionsort.prefix` is configured).
|
|
65
|
+
*/
|
|
66
|
+
export function compareByVersionDescending(a: string, b: string): number {
|
|
67
|
+
return -compareByVersion(a, b);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compares two strings using version-aware sorting in ascending order,
|
|
72
|
+
* matching git's `--sort=version:refname` (based on glibc's `strverscmp`).
|
|
73
|
+
*/
|
|
74
|
+
export function compareByVersion(a: string, b: string): number {
|
|
75
|
+
let i = 0;
|
|
76
|
+
let j = 0;
|
|
77
|
+
while (i < a.length && j < b.length) {
|
|
78
|
+
const ca = a.charCodeAt(i);
|
|
79
|
+
const cb = b.charCodeAt(j);
|
|
80
|
+
const aIsDigit = ca >= 48 && ca <= 57; // '0'-'9'
|
|
81
|
+
const bIsDigit = cb >= 48 && cb <= 57;
|
|
82
|
+
|
|
83
|
+
if (aIsDigit && bIsDigit) {
|
|
84
|
+
// Both in a digit run — compare numerically
|
|
85
|
+
let numA = 0;
|
|
86
|
+
while (i < a.length && a.charCodeAt(i) >= 48 && a.charCodeAt(i) <= 57) {
|
|
87
|
+
numA = numA * 10 + (a.charCodeAt(i) - 48);
|
|
88
|
+
i++;
|
|
89
|
+
}
|
|
90
|
+
let numB = 0;
|
|
91
|
+
while (j < b.length && b.charCodeAt(j) >= 48 && b.charCodeAt(j) <= 57) {
|
|
92
|
+
numB = numB * 10 + (b.charCodeAt(j) - 48);
|
|
93
|
+
j++;
|
|
94
|
+
}
|
|
95
|
+
if (numA !== numB) return numA - numB;
|
|
96
|
+
} else {
|
|
97
|
+
// Compare non-digit characters lexicographically
|
|
98
|
+
if (ca !== cb) return ca - cb;
|
|
99
|
+
i++;
|
|
100
|
+
j++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return a.length - b.length;
|
|
104
|
+
}
|
|
105
|
+
|
|
58
106
|
export function satisfies(
|
|
59
107
|
v: string | Version | null | undefined,
|
|
60
108
|
requirement: `${'=' | '>' | '>=' | '<' | '<='} ${string}`,
|