git-stack-cli 1.8.1 → 1.8.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/cjs/index.cjs +8 -2
- package/package.json +1 -2
- package/src/core/github.tsx +12 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -27281,6 +27281,9 @@ async function pr_list() {
|
|
|
27281
27281
|
invariant(username, "username must exist");
|
|
27282
27282
|
invariant(repo_path, "repo_path must exist");
|
|
27283
27283
|
const result_pr_list = await gh_json(`pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`);
|
|
27284
|
+
if (result_pr_list instanceof Error) {
|
|
27285
|
+
handle_error(result_pr_list.message);
|
|
27286
|
+
}
|
|
27284
27287
|
if (actions.isDebug()) {
|
|
27285
27288
|
actions.output(reactExports.createElement(Text, { dimColor: true },
|
|
27286
27289
|
reactExports.createElement(Text, null, "Github cache "),
|
|
@@ -27325,6 +27328,9 @@ async function pr_status(branch) {
|
|
|
27325
27328
|
reactExports.createElement(Text, { dimColor: true }, branch)));
|
|
27326
27329
|
}
|
|
27327
27330
|
const pr = await gh_json(`pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`);
|
|
27331
|
+
if (pr instanceof Error) {
|
|
27332
|
+
return null;
|
|
27333
|
+
}
|
|
27328
27334
|
actions.set((state) => {
|
|
27329
27335
|
state.pr[pr.headRefName] = pr;
|
|
27330
27336
|
});
|
|
@@ -27360,7 +27366,7 @@ async function gh_json(command) {
|
|
|
27360
27366
|
const options = { ignoreExitCode: true };
|
|
27361
27367
|
const cli_result = await cli(`gh ${command} > ${tmp_pr_json}`, options);
|
|
27362
27368
|
if (cli_result.code !== 0) {
|
|
27363
|
-
|
|
27369
|
+
return new Error(cli_result.output);
|
|
27364
27370
|
}
|
|
27365
27371
|
// read from file
|
|
27366
27372
|
const json_str = fs.readFileSync(tmp_pr_json, "utf-8");
|
|
@@ -34551,7 +34557,7 @@ async function command() {
|
|
|
34551
34557
|
.wrap(123)
|
|
34552
34558
|
// disallow unknown options
|
|
34553
34559
|
.strict()
|
|
34554
|
-
.version("1.8.
|
|
34560
|
+
.version("1.8.3" )
|
|
34555
34561
|
.showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
|
|
34556
34562
|
.help("help", "Show usage via `git stack help`").argv);
|
|
34557
34563
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-stack-cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "magus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"@types/yargs": "^17.0.29",
|
|
64
64
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
65
65
|
"@typescript-eslint/parser": "^6.9.0",
|
|
66
|
-
"bun": "^1.0.26",
|
|
67
66
|
"bun-types": "^1.0.21",
|
|
68
67
|
"eslint": "^8.52.0",
|
|
69
68
|
"eslint-import-resolver-typescript": "^3.6.1",
|
package/src/core/github.tsx
CHANGED
|
@@ -22,10 +22,14 @@ export async function pr_list(): Promise<Array<PullRequest>> {
|
|
|
22
22
|
invariant(username, "username must exist");
|
|
23
23
|
invariant(repo_path, "repo_path must exist");
|
|
24
24
|
|
|
25
|
-
const result_pr_list
|
|
25
|
+
const result_pr_list = await gh_json<Array<PullRequest>>(
|
|
26
26
|
`pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
+
if (result_pr_list instanceof Error) {
|
|
30
|
+
handle_error(result_pr_list.message);
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
if (actions.isDebug()) {
|
|
30
34
|
actions.output(
|
|
31
35
|
<Ink.Text dimColor>
|
|
@@ -93,10 +97,14 @@ export async function pr_status(branch: string): Promise<null | PullRequest> {
|
|
|
93
97
|
);
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
const pr
|
|
100
|
+
const pr = await gh_json<PullRequest>(
|
|
97
101
|
`pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`
|
|
98
102
|
);
|
|
99
103
|
|
|
104
|
+
if (pr instanceof Error) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
100
108
|
actions.set((state) => {
|
|
101
109
|
state.pr[pr.headRefName] = pr;
|
|
102
110
|
});
|
|
@@ -152,14 +160,14 @@ const JSON_FIELDS = "--json number,state,baseRefName,headRefName,commits,title,b
|
|
|
152
160
|
|
|
153
161
|
// consistent handle gh cli commands returning json
|
|
154
162
|
// redirect to tmp file to avoid scrollback overflow causing scrollback to be cleared
|
|
155
|
-
async function gh_json(command: string) {
|
|
163
|
+
async function gh_json<T>(command: string): Promise<T | Error> {
|
|
156
164
|
const tmp_pr_json = path.join(os.tmpdir(), "git-stack-gh.json");
|
|
157
165
|
|
|
158
166
|
const options = { ignoreExitCode: true };
|
|
159
167
|
const cli_result = await cli(`gh ${command} > ${tmp_pr_json}`, options);
|
|
160
168
|
|
|
161
169
|
if (cli_result.code !== 0) {
|
|
162
|
-
|
|
170
|
+
return new Error(cli_result.output);
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
// read from file
|