git-stack-cli 2.2.8 → 2.3.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/dist/js/index.js CHANGED
@@ -37296,6 +37296,7 @@ async function cli(unsafe_command, unsafe_options) {
37296
37296
  state.actions.debug(log.end(result));
37297
37297
  state.actions.debug(log.output(result));
37298
37298
  if (!options.ignoreExitCode && result.code !== 0) {
37299
+ state.actions.debug(log.non_zero_exit(result));
37299
37300
  reject(new Error(log.error(result)));
37300
37301
  } else {
37301
37302
  resolve(result);
@@ -37332,6 +37333,7 @@ cli.sync = function cli_sync(unsafe_command, unsafe_options) {
37332
37333
  state.actions.debug(log.end(result));
37333
37334
  state.actions.debug(log.output(result));
37334
37335
  if (!options.ignoreExitCode && result.code !== 0) {
37336
+ state.actions.debug(log.non_zero_exit(result));
37335
37337
  throw new Error(log.error(result));
37336
37338
  }
37337
37339
  return result;
@@ -37352,9 +37354,14 @@ var log = {
37352
37354
  return `${result.output}
37353
37355
  `;
37354
37356
  },
37355
- error(result) {
37357
+ non_zero_exit(result) {
37356
37358
  const { command, code, duration } = result;
37357
37359
  return `${command} (exit_code=${code} duration=${duration})`;
37360
+ },
37361
+ error(result) {
37362
+ const lines = [result.output, this.non_zero_exit(result)];
37363
+ return lines.join(`
37364
+ `);
37358
37365
  }
37359
37366
  };
37360
37367
 
@@ -37704,15 +37711,17 @@ function CherryPickCheck(props) {
37704
37711
  try {
37705
37712
  const git_dir = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
37706
37713
  const cherry_pick_file = path2.join(git_dir, "CHERRY_PICK_HEAD");
37707
- const is_cherry_pick = await safe_exists(cherry_pick_file);
37708
- const status = is_cherry_pick ? "prompt" : "done";
37709
- patch({ status });
37714
+ if (await safe_exists(cherry_pick_file)) {
37715
+ return patch({ status: "prompt" });
37716
+ }
37717
+ const git_sequencer_dir = (await cli(`git rev-parse --git-path sequencer`)).stdout;
37718
+ if (await safe_exists(git_sequencer_dir)) {
37719
+ return patch({ status: "prompt" });
37720
+ }
37721
+ patch({ status: "done" });
37710
37722
  } catch (err) {
37711
- actions2.error("Must be run from within a git repository.");
37712
37723
  if (err instanceof Error) {
37713
- if (actions2.isDebug()) {
37714
- actions2.error(err.message);
37715
- }
37724
+ actions2.error(err.message);
37716
37725
  }
37717
37726
  actions2.exit(11);
37718
37727
  }
@@ -38552,11 +38561,8 @@ function DetectInitialPR(props) {
38552
38561
  }
38553
38562
  patch({ status: "done" });
38554
38563
  } catch (err) {
38555
- actions2.error("Must be run from within a git repository.");
38556
38564
  if (err instanceof Error) {
38557
- if (actions2.isDebug()) {
38558
- actions2.error(err.message);
38559
- }
38565
+ actions2.error(err.message);
38560
38566
  }
38561
38567
  actions2.exit(9);
38562
38568
  }
@@ -38672,11 +38678,8 @@ function DirtyCheck(props) {
38672
38678
  patch({ status: "prompt" });
38673
38679
  }
38674
38680
  } catch (err) {
38675
- actions2.error("Must be run from within a git repository.");
38676
38681
  if (err instanceof Error) {
38677
- if (actions2.isDebug()) {
38678
- actions2.error(err.message);
38679
- }
38682
+ actions2.error(err.message);
38680
38683
  }
38681
38684
  actions2.exit(12);
38682
38685
  }
@@ -38757,9 +38760,7 @@ async function run() {
38757
38760
  } catch (err) {
38758
38761
  actions.error("Unable to gather git metadata.");
38759
38762
  if (err instanceof Error) {
38760
- if (actions.isDebug()) {
38761
- actions.error(err.message);
38762
- }
38763
+ actions.error(err.message);
38763
38764
  }
38764
38765
  actions.exit(7);
38765
38766
  }
@@ -38885,9 +38886,7 @@ async function run3() {
38885
38886
  } catch (err) {
38886
38887
  actions.error("Unable to retrieve local commit status.");
38887
38888
  if (err instanceof Error) {
38888
- if (actions.isDebug()) {
38889
- actions.error(err.message);
38890
- }
38889
+ actions.error(err.message);
38891
38890
  }
38892
38891
  }
38893
38892
  }
@@ -39234,34 +39233,35 @@ Rebase.run = async function run5() {
39234
39233
  const commit2 = commit_range.commit_list[i2];
39235
39234
  const commit_pr = commit_range.pr_lookup[commit2.branch_id || ""];
39236
39235
  const merged_pr = commit_pr?.state === "MERGED";
39236
+ const commit_message = /* @__PURE__ */ React34.createElement(Text, {
39237
+ color: colors.blue
39238
+ }, commit2.subject_line);
39237
39239
  if (merged_pr) {
39238
- if (actions.isDebug()) {
39239
- actions.output(/* @__PURE__ */ React34.createElement(FormatText, {
39240
- wrapper: /* @__PURE__ */ React34.createElement(Text, {
39241
- color: colors.yellow,
39242
- wrap: "truncate-end"
39243
- }),
39244
- message: "Dropping {commit_message} {pr_status}",
39245
- values: {
39246
- commit_message: /* @__PURE__ */ React34.createElement(Brackets, null, commit2.subject_line),
39247
- pr_status: /* @__PURE__ */ React34.createElement(Parens, null, "MERGED")
39248
- }
39249
- }));
39250
- }
39251
- continue;
39252
- }
39253
- if (actions.isDebug()) {
39254
39240
  actions.output(/* @__PURE__ */ React34.createElement(FormatText, {
39255
39241
  wrapper: /* @__PURE__ */ React34.createElement(Text, {
39256
39242
  color: colors.yellow,
39257
39243
  wrap: "truncate-end"
39258
39244
  }),
39259
- message: "Picking {commit_message}",
39245
+ message: "Dropping {pr_status} {commit_message}",
39260
39246
  values: {
39261
- commit_message: /* @__PURE__ */ React34.createElement(Brackets, null, commit2.subject_line)
39247
+ pr_status: /* @__PURE__ */ React34.createElement(Text, {
39248
+ color: colors.purple
39249
+ }, "MERGED"),
39250
+ commit_message
39262
39251
  }
39263
39252
  }));
39253
+ continue;
39264
39254
  }
39255
+ actions.output(/* @__PURE__ */ React34.createElement(FormatText, {
39256
+ wrapper: /* @__PURE__ */ React34.createElement(Text, {
39257
+ color: colors.yellow,
39258
+ wrap: "truncate-end"
39259
+ }),
39260
+ message: "Picking {commit_message}",
39261
+ values: {
39262
+ commit_message
39263
+ }
39264
+ }));
39265
39265
  picked_commit_list.push(commit2);
39266
39266
  }
39267
39267
  if (picked_commit_list.length > 0) {
@@ -39271,33 +39271,30 @@ Rebase.run = async function run5() {
39271
39271
  }
39272
39272
  await cli(`git branch -f ${branch_name} ${temp_branch_name}`);
39273
39273
  restore_git();
39274
- const next_commit_range = await range();
39275
- actions.output(/* @__PURE__ */ React34.createElement(FormatText, {
39276
- wrapper: /* @__PURE__ */ React34.createElement(Text, {
39277
- color: colors.green
39278
- }),
39279
- message: "✅ {branch_name} in sync with {origin_branch}",
39280
- values: {
39281
- branch_name: /* @__PURE__ */ React34.createElement(Brackets, null, branch_name),
39282
- origin_branch: /* @__PURE__ */ React34.createElement(Brackets, null, master_branch)
39283
- }
39284
- }));
39285
39274
  actions.unregister_abort_handler();
39286
- actions.set((state2) => {
39287
- state2.commit_range = next_commit_range;
39288
- });
39289
- actions.output(/* @__PURE__ */ React34.createElement(Status, null));
39290
- actions.exit(0);
39291
39275
  } catch (err) {
39292
39276
  actions.error("Unable to rebase.");
39293
39277
  if (err instanceof Error) {
39294
- if (actions.isDebug()) {
39295
- actions.error(err.message);
39296
- }
39278
+ actions.error(err.message);
39297
39279
  }
39298
- handle_exit();
39299
39280
  actions.exit(20);
39300
39281
  }
39282
+ const next_commit_range = await range();
39283
+ actions.output(/* @__PURE__ */ React34.createElement(FormatText, {
39284
+ wrapper: /* @__PURE__ */ React34.createElement(Text, {
39285
+ color: colors.green
39286
+ }),
39287
+ message: "✅ {branch_name} in sync with {origin_branch}",
39288
+ values: {
39289
+ branch_name: /* @__PURE__ */ React34.createElement(Brackets, null, branch_name),
39290
+ origin_branch: /* @__PURE__ */ React34.createElement(Brackets, null, master_branch)
39291
+ }
39292
+ }));
39293
+ actions.set((state2) => {
39294
+ state2.commit_range = next_commit_range;
39295
+ });
39296
+ actions.output(/* @__PURE__ */ React34.createElement(Status, null));
39297
+ actions.exit(0);
39301
39298
  function restore_git() {
39302
39299
  const spawn_options = { ignoreExitCode: true };
39303
39300
  cli.sync(`git reset --hard`, spawn_options);
@@ -39418,7 +39415,6 @@ async function run6() {
39418
39415
  if (!argv.verbose) {
39419
39416
  actions.error("Try again with `--verbose` to see more information.");
39420
39417
  }
39421
- handle_exit();
39422
39418
  actions.exit(16);
39423
39419
  }
39424
39420
  function restore_git() {
@@ -40302,7 +40298,6 @@ async function run9() {
40302
40298
  if (!argv.verbose) {
40303
40299
  actions.error("Try again with `--verbose` to see more information.");
40304
40300
  }
40305
- handle_exit();
40306
40301
  actions.exit(18);
40307
40302
  }
40308
40303
  function get_push_group_list() {
@@ -40526,11 +40521,8 @@ function RebaseCheck(props) {
40526
40521
  const status = is_rebase ? "prompt" : "done";
40527
40522
  patch({ status });
40528
40523
  } catch (err) {
40529
- actions2.error("Must be run from within a git repository.");
40530
40524
  if (err instanceof Error) {
40531
- if (actions2.isDebug()) {
40532
- actions2.error(err.message);
40533
- }
40525
+ actions2.error(err.message);
40534
40526
  }
40535
40527
  actions2.exit(13);
40536
40528
  }
@@ -40559,9 +40551,7 @@ async function run10() {
40559
40551
  } catch (err) {
40560
40552
  actions.error("Unable to log verbose debug information.");
40561
40553
  if (err instanceof Error) {
40562
- if (actions.isDebug()) {
40563
- actions.error(err.message);
40564
- }
40554
+ actions.error(err.message);
40565
40555
  }
40566
40556
  actions.exit(14);
40567
40557
  }
@@ -45663,7 +45653,7 @@ var yargs_default = Yargs;
45663
45653
 
45664
45654
  // src/command.ts
45665
45655
  async function command2() {
45666
- return yargs_default(hideBin(process.argv)).scriptName("git stack").usage("Usage: git stack [command] [options]").command("$0", "Sync commit ranges to Github", (yargs) => yargs.options(DefaultOptions)).command("fixup [commit]", "Amend staged changes to a specific commit in history", (yargs) => yargs.positional("commit", FixupOptions.commit)).command("log [args...]", "Print an abbreviated log with numbered commits, useful for git stack fixup", (yargs) => yargs.strict(false)).command("rebase", "Update local branch via rebase with latest changes from origin master branch", (yargs) => yargs).option("verbose", GlobalOptions.verbose).wrap(123).strict().version("2.2.8").showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`").help("help", "Show usage via `git stack help`").argv;
45656
+ return yargs_default(hideBin(process.argv)).scriptName("git stack").usage("Usage: git stack [command] [options]").command("$0", "Sync commit ranges to Github", (yargs) => yargs.options(DefaultOptions)).command("fixup [commit]", "Amend staged changes to a specific commit in history", (yargs) => yargs.positional("commit", FixupOptions.commit)).command("log [args...]", "Print an abbreviated log with numbered commits, useful for git stack fixup", (yargs) => yargs.strict(false)).command("rebase", "Update local branch via rebase with latest changes from origin master branch", (yargs) => yargs).option("verbose", GlobalOptions.verbose).wrap(123).strict().version("2.3.0").showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`").help("help", "Show usage via `git stack help`").argv;
45667
45657
  }
45668
45658
  var GlobalOptions = {
45669
45659
  verbose: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "2.2.8",
3
+ "version": "2.3.0",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -73,18 +73,19 @@ export function CherryPickCheck(props: Props) {
73
73
  const git_dir = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
74
74
 
75
75
  const cherry_pick_file = path.join(git_dir, "CHERRY_PICK_HEAD");
76
- const is_cherry_pick = await safe_exists(cherry_pick_file);
76
+ if (await safe_exists(cherry_pick_file)) {
77
+ return patch({ status: "prompt" });
78
+ }
77
79
 
78
- const status = is_cherry_pick ? "prompt" : "done";
80
+ const git_sequencer_dir = (await cli(`git rev-parse --git-path sequencer`)).stdout;
81
+ if (await safe_exists(git_sequencer_dir)) {
82
+ return patch({ status: "prompt" });
83
+ }
79
84
 
80
- patch({ status });
85
+ patch({ status: "done" });
81
86
  } catch (err) {
82
- actions.error("Must be run from within a git repository.");
83
-
84
87
  if (err instanceof Error) {
85
- if (actions.isDebug()) {
86
- actions.error(err.message);
87
- }
88
+ actions.error(err.message);
88
89
  }
89
90
 
90
91
  actions.exit(11);
@@ -130,12 +130,8 @@ export function DetectInitialPR(props: Props) {
130
130
 
131
131
  patch({ status: "done" });
132
132
  } catch (err) {
133
- actions.error("Must be run from within a git repository.");
134
-
135
133
  if (err instanceof Error) {
136
- if (actions.isDebug()) {
137
- actions.error(err.message);
138
- }
134
+ actions.error(err.message);
139
135
  }
140
136
 
141
137
  actions.exit(9);
@@ -112,12 +112,8 @@ export function DirtyCheck(props: Props) {
112
112
  patch({ status: "prompt" });
113
113
  }
114
114
  } catch (err) {
115
- actions.error("Must be run from within a git repository.");
116
-
117
115
  if (err instanceof Error) {
118
- if (actions.isDebug()) {
119
- actions.error(err.message);
120
- }
116
+ actions.error(err.message);
121
117
  }
122
118
 
123
119
  actions.exit(12);
@@ -112,9 +112,7 @@ async function run() {
112
112
  actions.error("Unable to gather git metadata.");
113
113
 
114
114
  if (err instanceof Error) {
115
- if (actions.isDebug()) {
116
- actions.error(err.message);
117
- }
115
+ actions.error(err.message);
118
116
  }
119
117
 
120
118
  actions.exit(7);
@@ -57,9 +57,7 @@ async function run() {
57
57
  actions.error("Unable to retrieve local commit status.");
58
58
 
59
59
  if (err instanceof Error) {
60
- if (actions.isDebug()) {
61
- actions.error(err.message);
62
- }
60
+ actions.error(err.message);
63
61
  }
64
62
  }
65
63
  }
@@ -136,7 +136,6 @@ async function run() {
136
136
  actions.error("Try again with `--verbose` to see more information.");
137
137
  }
138
138
 
139
- handle_exit();
140
139
  actions.exit(16);
141
140
  }
142
141
 
@@ -79,12 +79,8 @@ export function RebaseCheck(props: Props) {
79
79
  const status = is_rebase ? "prompt" : "done";
80
80
  patch({ status });
81
81
  } catch (err) {
82
- actions.error("Must be run from within a git repository.");
83
-
84
82
  if (err instanceof Error) {
85
- if (actions.isDebug()) {
86
- actions.error(err.message);
87
- }
83
+ actions.error(err.message);
88
84
  }
89
85
 
90
86
  actions.exit(13);
@@ -142,7 +142,6 @@ async function run() {
142
142
  actions.error("Try again with `--verbose` to see more information.");
143
143
  }
144
144
 
145
- handle_exit();
146
145
  actions.exit(18);
147
146
  }
148
147
 
@@ -34,9 +34,7 @@ async function run() {
34
34
  actions.error("Unable to log verbose debug information.");
35
35
 
36
36
  if (err instanceof Error) {
37
- if (actions.isDebug()) {
38
- actions.error(err.message);
39
- }
37
+ actions.error(err.message);
40
38
  }
41
39
 
42
40
  actions.exit(14);
@@ -7,7 +7,6 @@ import * as Ink from "ink-cjs";
7
7
  import { Await } from "~/app/Await";
8
8
  import { Brackets } from "~/app/Brackets";
9
9
  import { FormatText } from "~/app/FormatText";
10
- import { Parens } from "~/app/Parens";
11
10
  import { Status } from "~/app/Status";
12
11
  import { Store } from "~/app/Store";
13
12
  import * as CommitMetadata from "~/core/CommitMetadata";
@@ -72,36 +71,33 @@ Rebase.run = async function run() {
72
71
 
73
72
  // drop commits that are in groups of merged PRs
74
73
  const merged_pr = commit_pr?.state === "MERGED";
74
+ const commit_message = <Ink.Text color={colors.blue}>{commit.subject_line}</Ink.Text>;
75
75
 
76
76
  if (merged_pr) {
77
- if (actions.isDebug()) {
78
- actions.output(
79
- <FormatText
80
- wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
81
- message="Dropping {commit_message} {pr_status}"
82
- values={{
83
- commit_message: <Brackets>{commit.subject_line}</Brackets>,
84
- pr_status: <Parens>MERGED</Parens>,
85
- }}
86
- />,
87
- );
88
- }
89
-
90
- continue;
91
- }
92
-
93
- if (actions.isDebug()) {
94
77
  actions.output(
95
78
  <FormatText
96
79
  wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
97
- message="Picking {commit_message}"
80
+ message="Dropping {pr_status} {commit_message}"
98
81
  values={{
99
- commit_message: <Brackets>{commit.subject_line}</Brackets>,
82
+ pr_status: <Ink.Text color={colors.purple}>MERGED</Ink.Text>,
83
+ commit_message,
100
84
  }}
101
85
  />,
102
86
  );
87
+
88
+ continue;
103
89
  }
104
90
 
91
+ actions.output(
92
+ <FormatText
93
+ wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
94
+ message="Picking {commit_message}"
95
+ values={{
96
+ commit_message,
97
+ }}
98
+ />,
99
+ );
100
+
105
101
  picked_commit_list.push(commit);
106
102
  }
107
103
 
@@ -121,41 +117,38 @@ Rebase.run = async function run() {
121
117
 
122
118
  restore_git();
123
119
 
124
- const next_commit_range = await CommitMetadata.range();
125
-
126
- actions.output(
127
- <FormatText
128
- wrapper={<Ink.Text color={colors.green} />}
129
- message="✅ {branch_name} in sync with {origin_branch}"
130
- values={{
131
- branch_name: <Brackets>{branch_name}</Brackets>,
132
- origin_branch: <Brackets>{master_branch}</Brackets>,
133
- }}
134
- />,
135
- );
136
-
137
120
  actions.unregister_abort_handler();
138
-
139
- actions.set((state) => {
140
- state.commit_range = next_commit_range;
141
- });
142
-
143
- actions.output(<Status />);
144
-
145
- actions.exit(0);
146
121
  } catch (err) {
147
122
  actions.error("Unable to rebase.");
148
123
 
149
124
  if (err instanceof Error) {
150
- if (actions.isDebug()) {
151
- actions.error(err.message);
152
- }
125
+ actions.error(err.message);
153
126
  }
154
127
 
155
- handle_exit();
156
128
  actions.exit(20);
157
129
  }
158
130
 
131
+ const next_commit_range = await CommitMetadata.range();
132
+
133
+ actions.output(
134
+ <FormatText
135
+ wrapper={<Ink.Text color={colors.green} />}
136
+ message="✅ {branch_name} in sync with {origin_branch}"
137
+ values={{
138
+ branch_name: <Brackets>{branch_name}</Brackets>,
139
+ origin_branch: <Brackets>{master_branch}</Brackets>,
140
+ }}
141
+ />,
142
+ );
143
+
144
+ actions.set((state) => {
145
+ state.commit_range = next_commit_range;
146
+ });
147
+
148
+ actions.output(<Status />);
149
+
150
+ actions.exit(0);
151
+
159
152
  // cleanup git operations if cancelled during manual rebase
160
153
  function restore_git() {
161
154
  // signint handler MUST run synchronously
package/src/core/cli.ts CHANGED
@@ -82,6 +82,7 @@ export async function cli(
82
82
  state.actions.debug(log.output(result));
83
83
 
84
84
  if (!options.ignoreExitCode && result.code !== 0) {
85
+ state.actions.debug(log.non_zero_exit(result));
85
86
  reject(new Error(log.error(result)));
86
87
  } else {
87
88
  resolve(result);
@@ -133,6 +134,7 @@ cli.sync = function cli_sync(
133
134
  state.actions.debug(log.output(result));
134
135
 
135
136
  if (!options.ignoreExitCode && result.code !== 0) {
137
+ state.actions.debug(log.non_zero_exit(result));
136
138
  throw new Error(log.error(result));
137
139
  }
138
140
 
@@ -157,8 +159,13 @@ const log = {
157
159
  return `${result.output}\n`;
158
160
  },
159
161
 
160
- error(result: Return) {
162
+ non_zero_exit(result: Return) {
161
163
  const { command, code, duration } = result;
162
164
  return `${command} (exit_code=${code} duration=${duration})`;
163
165
  },
166
+
167
+ error(result: Return) {
168
+ const lines = [result.output, this.non_zero_exit(result)];
169
+ return lines.join("\n");
170
+ },
164
171
  };