git-stack-cli 1.8.0 → 1.8.1

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.
@@ -27273,8 +27273,6 @@ const RE$1 = {
27273
27273
  group_title: new RegExp(TEMPLATE$1.group_title("(?<title>[^\\n^\\r]+)"), "i"),
27274
27274
  };
27275
27275
 
27276
- // prettier-ignore
27277
- const JSON_FIELDS = "--json number,state,baseRefName,headRefName,commits,title,body,url";
27278
27276
  async function pr_list() {
27279
27277
  const state = Store.getState();
27280
27278
  const actions = state.actions;
@@ -27282,13 +27280,7 @@ async function pr_list() {
27282
27280
  const repo_path = state.repo_path;
27283
27281
  invariant(username, "username must exist");
27284
27282
  invariant(repo_path, "repo_path must exist");
27285
- const cli_result = await cli(`gh pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`, {
27286
- ignoreExitCode: true,
27287
- });
27288
- if (cli_result.code !== 0) {
27289
- handle_error(cli_result.output);
27290
- }
27291
- const result_pr_list = JSON.parse(cli_result.stdout);
27283
+ const result_pr_list = await gh_json(`pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`);
27292
27284
  if (actions.isDebug()) {
27293
27285
  actions.output(reactExports.createElement(Text, { dimColor: true },
27294
27286
  reactExports.createElement(Text, null, "Github cache "),
@@ -27332,14 +27324,7 @@ async function pr_status(branch) {
27332
27324
  reactExports.createElement(Text, null, " "),
27333
27325
  reactExports.createElement(Text, { dimColor: true }, branch)));
27334
27326
  }
27335
- const cli_result = await cli(`gh pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`, {
27336
- ignoreExitCode: true,
27337
- });
27338
- if (cli_result.code !== 0) {
27339
- // handle_error(cli_result.output);
27340
- return null;
27341
- }
27342
- const pr = JSON.parse(cli_result.stdout);
27327
+ const pr = await gh_json(`pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`);
27343
27328
  actions.set((state) => {
27344
27329
  state.pr[pr.headRefName] = pr;
27345
27330
  });
@@ -27366,6 +27351,22 @@ async function pr_edit(args) {
27366
27351
  handle_error(cli_result.output);
27367
27352
  }
27368
27353
  }
27354
+ // prettier-ignore
27355
+ const JSON_FIELDS = "--json number,state,baseRefName,headRefName,commits,title,body,url";
27356
+ // consistent handle gh cli commands returning json
27357
+ // redirect to tmp file to avoid scrollback overflow causing scrollback to be cleared
27358
+ async function gh_json(command) {
27359
+ const tmp_pr_json = path.join(os.tmpdir(), "git-stack-gh.json");
27360
+ const options = { ignoreExitCode: true };
27361
+ const cli_result = await cli(`gh ${command} > ${tmp_pr_json}`, options);
27362
+ if (cli_result.code !== 0) {
27363
+ handle_error(cli_result.output);
27364
+ }
27365
+ // read from file
27366
+ const json_str = fs.readFileSync(tmp_pr_json, "utf-8");
27367
+ const json = JSON.parse(json_str);
27368
+ return json;
27369
+ }
27369
27370
  function handle_error(output) {
27370
27371
  const state = Store.getState();
27371
27372
  const actions = state.actions;
@@ -27658,7 +27659,7 @@ async function run$4() {
27658
27659
  process.once("SIGINT", handle_exit);
27659
27660
  const temp_branch_name = `${branch_name}_${short_id()}`;
27660
27661
  try {
27661
- actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
27662
+ // actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
27662
27663
  // must perform rebase from repo root for applying git patch
27663
27664
  process.chdir(repo_root);
27664
27665
  await cli(`pwd`);
@@ -27976,7 +27977,7 @@ async function run$3() {
27976
27977
  }
27977
27978
  actions.debug(`rebase_merge_base = ${rebase_merge_base}`);
27978
27979
  actions.debug(`rebase_group_index = ${rebase_group_index}`);
27979
- actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
27980
+ // actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
27980
27981
  try {
27981
27982
  // must perform rebase from repo root for applying git patch
27982
27983
  process.chdir(repo_root);
@@ -28062,7 +28063,7 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28062
28063
  `GIT_REVISE_TODO="${git_revise_todo}"`,
28063
28064
  `git`,
28064
28065
  `revise --edit -i ${rebase_merge_base}`,
28065
- ]);
28066
+ ], { stdio: ["ignore", "ignore", "ignore"] });
28066
28067
  // early return since we do not need to sync
28067
28068
  if (!argv.sync) {
28068
28069
  return;
@@ -34550,7 +34551,7 @@ async function command() {
34550
34551
  .wrap(123)
34551
34552
  // disallow unknown options
34552
34553
  .strict()
34553
- .version("1.8.0" )
34554
+ .version("1.8.1" )
34554
34555
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34555
34556
  .help("help", "Show usage via `git stack help`").argv);
34556
34557
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@ async function run() {
43
43
  const temp_branch_name = `${branch_name}_${short_id()}`;
44
44
 
45
45
  try {
46
- actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
46
+ // actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
47
47
 
48
48
  // must perform rebase from repo root for applying git patch
49
49
  process.chdir(repo_root);
@@ -83,7 +83,8 @@ async function run() {
83
83
 
84
84
  actions.debug(`rebase_merge_base = ${rebase_merge_base}`);
85
85
  actions.debug(`rebase_group_index = ${rebase_group_index}`);
86
- actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
86
+
87
+ // actions.debug(`commit_range=${JSON.stringify(commit_range, null, 2)}`);
87
88
 
88
89
  try {
89
90
  // must perform rebase from repo root for applying git patch
@@ -153,12 +154,15 @@ async function run() {
153
154
 
154
155
  // execute cli with temporary git sequence editor script
155
156
  // revise from merge base to pick correct commits
156
- await cli([
157
- `GIT_EDITOR="${tmp_git_sequence_editor_path}"`,
158
- `GIT_REVISE_TODO="${git_revise_todo}"`,
159
- `git`,
160
- `revise --edit -i ${rebase_merge_base}`,
161
- ]);
157
+ await cli(
158
+ [
159
+ `GIT_EDITOR="${tmp_git_sequence_editor_path}"`,
160
+ `GIT_REVISE_TODO="${git_revise_todo}"`,
161
+ `git`,
162
+ `revise --edit -i ${rebase_merge_base}`,
163
+ ],
164
+ { stdio: ["ignore", "ignore", "ignore"] }
165
+ );
162
166
 
163
167
  // early return since we do not need to sync
164
168
  if (!argv.sync) {
@@ -13,9 +13,6 @@ import { colors } from "~/core/colors";
13
13
  import { invariant } from "~/core/invariant";
14
14
  import { safe_quote } from "~/core/safe_quote";
15
15
 
16
- // prettier-ignore
17
- const JSON_FIELDS = "--json number,state,baseRefName,headRefName,commits,title,body,url";
18
-
19
16
  export async function pr_list(): Promise<Array<PullRequest>> {
20
17
  const state = Store.getState();
21
18
  const actions = state.actions;
@@ -25,19 +22,10 @@ export async function pr_list(): Promise<Array<PullRequest>> {
25
22
  invariant(username, "username must exist");
26
23
  invariant(repo_path, "repo_path must exist");
27
24
 
28
- const cli_result = await cli(
29
- `gh pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`,
30
- {
31
- ignoreExitCode: true,
32
- }
25
+ const result_pr_list: Array<PullRequest> = await gh_json(
26
+ `pr list --repo ${repo_path} --author ${username} --state open ${JSON_FIELDS}`
33
27
  );
34
28
 
35
- if (cli_result.code !== 0) {
36
- handle_error(cli_result.output);
37
- }
38
-
39
- const result_pr_list: Array<PullRequest> = JSON.parse(cli_result.stdout);
40
-
41
29
  if (actions.isDebug()) {
42
30
  actions.output(
43
31
  <Ink.Text dimColor>
@@ -105,20 +93,10 @@ export async function pr_status(branch: string): Promise<null | PullRequest> {
105
93
  );
106
94
  }
107
95
 
108
- const cli_result = await cli(
109
- `gh pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`,
110
- {
111
- ignoreExitCode: true,
112
- }
96
+ const pr: PullRequest = await gh_json(
97
+ `pr view ${branch} --repo ${repo_path} ${JSON_FIELDS}`
113
98
  );
114
99
 
115
- if (cli_result.code !== 0) {
116
- // handle_error(cli_result.output);
117
- return null;
118
- }
119
-
120
- const pr: PullRequest = JSON.parse(cli_result.stdout);
121
-
122
100
  actions.set((state) => {
123
101
  state.pr[pr.headRefName] = pr;
124
102
  });
@@ -169,6 +147,27 @@ export async function pr_edit(args: EditPullRequestArgs) {
169
147
  }
170
148
  }
171
149
 
150
+ // prettier-ignore
151
+ const JSON_FIELDS = "--json number,state,baseRefName,headRefName,commits,title,body,url";
152
+
153
+ // consistent handle gh cli commands returning json
154
+ // redirect to tmp file to avoid scrollback overflow causing scrollback to be cleared
155
+ async function gh_json(command: string) {
156
+ const tmp_pr_json = path.join(os.tmpdir(), "git-stack-gh.json");
157
+
158
+ const options = { ignoreExitCode: true };
159
+ const cli_result = await cli(`gh ${command} > ${tmp_pr_json}`, options);
160
+
161
+ if (cli_result.code !== 0) {
162
+ handle_error(cli_result.output);
163
+ }
164
+
165
+ // read from file
166
+ const json_str = fs.readFileSync(tmp_pr_json, "utf-8");
167
+ const json = JSON.parse(json_str);
168
+ return json;
169
+ }
170
+
172
171
  function handle_error(output: string): never {
173
172
  const state = Store.getState();
174
173
  const actions = state.actions;