git-stack-cli 2.9.1 → 2.9.3
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/dist/js/index.js +80 -80
- package/package.json +1 -1
- package/scripts/bun-build.ts +4 -0
- package/scripts/core/get_define.ts +1 -1
- package/src/app/App.tsx +13 -8
- package/src/app/AutoUpdate.tsx +6 -0
- package/src/app/FetchPullRequests.tsx +40 -0
- package/src/app/GithubApiError.tsx +6 -1
- package/src/app/PostRebaseStatus.tsx +7 -4
- package/src/app/PreManualRebase.tsx +6 -1
- package/src/app/Status.tsx +6 -1
- package/src/app/Store.tsx +4 -8
- package/src/app/SyncGithub.tsx +31 -7
- package/src/command.ts +5 -1
- package/src/commands/Config.tsx +6 -1
- package/src/commands/Fixup.tsx +6 -1
- package/src/commands/Log.tsx +7 -1
- package/src/core/CommitMetadata.ts +44 -30
- package/src/core/github.tsx +87 -29
package/src/core/github.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import * as Ink from "ink-cjs";
|
|
8
8
|
|
|
9
9
|
import { Brackets } from "~/app/Brackets";
|
|
10
|
+
import { FormatText } from "~/app/FormatText";
|
|
10
11
|
import { Store } from "~/app/Store";
|
|
11
12
|
import { Timer } from "~/core/Timer";
|
|
12
13
|
import { cli } from "~/core/cli";
|
|
@@ -38,16 +39,19 @@ export async function pr_list(): Promise<Array<PullRequest>> {
|
|
|
38
39
|
|
|
39
40
|
if (actions.isDebug()) {
|
|
40
41
|
actions.output(
|
|
41
|
-
<
|
|
42
|
-
<Ink.Text
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
<FormatText
|
|
43
|
+
wrapper={<Ink.Text dimColor />}
|
|
44
|
+
message="Github cache {count} open PRs from {repo_path} authored by {username}"
|
|
45
|
+
values={{
|
|
46
|
+
count: (
|
|
47
|
+
<Ink.Text bold color={colors.yellow}>
|
|
48
|
+
{result_pr_list.length}
|
|
49
|
+
</Ink.Text>
|
|
50
|
+
),
|
|
51
|
+
repo_path: <Brackets>{repo_path}</Brackets>,
|
|
52
|
+
username: <Brackets>{username}</Brackets>,
|
|
53
|
+
}}
|
|
54
|
+
/>,
|
|
51
55
|
);
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -76,15 +80,11 @@ export async function pr_status(branch: string): Promise<null | PullRequest> {
|
|
|
76
80
|
if (cache) {
|
|
77
81
|
if (actions.isDebug()) {
|
|
78
82
|
actions.debug(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
</Ink.Text>
|
|
85
|
-
<Ink.Text> </Ink.Text>
|
|
86
|
-
<Ink.Text dimColor>{branch}</Ink.Text>
|
|
87
|
-
</Ink.Text>,
|
|
83
|
+
cache_message({
|
|
84
|
+
hit: true,
|
|
85
|
+
message: "Github pr_status cache",
|
|
86
|
+
extra: branch,
|
|
87
|
+
}),
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -93,15 +93,11 @@ export async function pr_status(branch: string): Promise<null | PullRequest> {
|
|
|
93
93
|
|
|
94
94
|
if (actions.isDebug()) {
|
|
95
95
|
actions.debug(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</Ink.Text>
|
|
102
|
-
<Ink.Text> </Ink.Text>
|
|
103
|
-
<Ink.Text dimColor>{branch}</Ink.Text>
|
|
104
|
-
</Ink.Text>,
|
|
96
|
+
cache_message({
|
|
97
|
+
hit: false,
|
|
98
|
+
message: "Github pr_status cache",
|
|
99
|
+
extra: branch,
|
|
100
|
+
}),
|
|
105
101
|
);
|
|
106
102
|
}
|
|
107
103
|
|
|
@@ -246,14 +242,46 @@ export async function pr_draft(args: DraftPullRequestArgs) {
|
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
export async function pr_diff(number: number) {
|
|
249
|
-
|
|
245
|
+
const state = Store.getState();
|
|
246
|
+
const actions = state.actions;
|
|
247
|
+
|
|
248
|
+
const maybe_diff = state.cache_pr_diff[number];
|
|
249
|
+
|
|
250
|
+
if (maybe_diff) {
|
|
251
|
+
if (actions.isDebug()) {
|
|
252
|
+
actions.debug(
|
|
253
|
+
cache_message({
|
|
254
|
+
hit: true,
|
|
255
|
+
message: "Github pr_diff cache",
|
|
256
|
+
extra: number,
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return maybe_diff;
|
|
262
|
+
}
|
|
250
263
|
|
|
264
|
+
if (actions.isDebug()) {
|
|
265
|
+
actions.debug(
|
|
266
|
+
cache_message({
|
|
267
|
+
hit: false,
|
|
268
|
+
message: "Github pr_diff cache",
|
|
269
|
+
extra: number,
|
|
270
|
+
}),
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// https://cli.github.com/manual/gh_pr_diff
|
|
251
275
|
const cli_result = await cli(`gh pr diff --color=never ${number}`);
|
|
252
276
|
|
|
253
277
|
if (cli_result.code !== 0) {
|
|
254
278
|
handle_error(cli_result.output);
|
|
255
279
|
}
|
|
256
280
|
|
|
281
|
+
actions.set((state) => {
|
|
282
|
+
state.cache_pr_diff[number] = cli_result.output;
|
|
283
|
+
});
|
|
284
|
+
|
|
257
285
|
return cli_result.stdout;
|
|
258
286
|
}
|
|
259
287
|
|
|
@@ -321,6 +349,36 @@ function safe_filename(value: string): string {
|
|
|
321
349
|
return value.replace(RE.non_alphanumeric_dash, "-");
|
|
322
350
|
}
|
|
323
351
|
|
|
352
|
+
type CacheMessageArgs = {
|
|
353
|
+
hit: boolean;
|
|
354
|
+
message: React.ReactNode;
|
|
355
|
+
extra: React.ReactNode;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
function cache_message(args: CacheMessageArgs) {
|
|
359
|
+
const status = args.hit ? (
|
|
360
|
+
<Ink.Text bold color={colors.green}>
|
|
361
|
+
HIT
|
|
362
|
+
</Ink.Text>
|
|
363
|
+
) : (
|
|
364
|
+
<Ink.Text bold color={colors.red}>
|
|
365
|
+
MISS
|
|
366
|
+
</Ink.Text>
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<FormatText
|
|
371
|
+
wrapper={<Ink.Text dimColor />}
|
|
372
|
+
message="{message} {status} {extra}"
|
|
373
|
+
values={{
|
|
374
|
+
message: args.message,
|
|
375
|
+
status,
|
|
376
|
+
extra: args.extra,
|
|
377
|
+
}}
|
|
378
|
+
/>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
324
382
|
type Commit = {
|
|
325
383
|
authoredDate: string; // "2023-10-22T23:13:35Z"
|
|
326
384
|
authors: [
|