git-stack-cli 1.2.6 → 1.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.
@@ -26197,9 +26197,10 @@ function LogTimestamp() {
26197
26197
  }
26198
26198
 
26199
26199
  const BaseStore = createStore()(immer((set, get) => ({
26200
- argv: null,
26201
- ink: null,
26202
- cwd: null,
26200
+ // set immediately in `index.tsx` so no `null` scenario
26201
+ argv: {},
26202
+ ink: {},
26203
+ cwd: "",
26203
26204
  username: null,
26204
26205
  repo_path: null,
26205
26206
  repo_root: null,
@@ -26675,12 +26676,6 @@ function AutoUpdate(props) {
26675
26676
  status));
26676
26677
  }
26677
26678
 
26678
- function invariant(condition, message) {
26679
- if (!condition) {
26680
- throw new Error(message);
26681
- }
26682
- }
26683
-
26684
26679
  function serialize(obj) {
26685
26680
  if (obj instanceof Map) {
26686
26681
  return {
@@ -26728,7 +26723,6 @@ function Debug() {
26728
26723
  }
26729
26724
  }, [argv]);
26730
26725
  reactExports.useEffect(function syncStateJson() {
26731
- invariant(state.cwd, "state.cwd must exist");
26732
26726
  if (!argv?.["write-state-json"]) {
26733
26727
  return;
26734
26728
  }
@@ -26783,6 +26777,12 @@ function cache(cacheable) {
26783
26777
  return { reset, check, read };
26784
26778
  }
26785
26779
 
26780
+ function invariant(condition, message) {
26781
+ if (!condition) {
26782
+ throw new Error(message);
26783
+ }
26784
+ }
26785
+
26786
26786
  function Await(props) {
26787
26787
  const [display_fallback, set_display_fallback] = reactExports.useState(false);
26788
26788
  // const id = React.useId();
@@ -26983,15 +26983,12 @@ function CheckGitRevise(props) {
26983
26983
  }
26984
26984
 
26985
26985
  function GatherMetadata(props) {
26986
- const argv = Store.useState((state) => state.argv);
26987
- invariant(argv, "argv must exist");
26988
26986
  const fallback = (reactExports.createElement(Text, { color: colors.yellow }, "Gathering local git information..."));
26989
26987
  return (reactExports.createElement(Await, { fallback: fallback, function: gather_metadata$1 }, props.children));
26990
26988
  }
26991
26989
  async function gather_metadata$1() {
26992
26990
  const actions = Store.getState().actions;
26993
26991
  const argv = Store.getState().argv;
26994
- invariant(argv, "argv must exist");
26995
26992
  try {
26996
26993
  // default to master branch, fallback to main
26997
26994
  let master_branch;
@@ -27083,8 +27080,6 @@ function format_time(date) {
27083
27080
  }
27084
27081
 
27085
27082
  function GithubApiError() {
27086
- const argv = Store.useState((state) => state.argv);
27087
- invariant(argv, "argv must exist");
27088
27083
  return reactExports.createElement(Await, { fallback: null, function: run$4 });
27089
27084
  }
27090
27085
  async function run$4() {
@@ -27398,7 +27393,8 @@ async function range(commit_group_map) {
27398
27393
  return { invalid, group_list, commit_list, pr_lookup, UNASSIGNED };
27399
27394
  }
27400
27395
  async function get_commit_list() {
27401
- const log_result = await cli(`git log master..HEAD --oneline --format=%H --color=never`);
27396
+ const master_branch = Store.getState().master_branch;
27397
+ const log_result = await cli(`git log ${master_branch}..HEAD --oneline --format=%H --color=never`);
27402
27398
  if (!log_result.stdout) {
27403
27399
  return [];
27404
27400
  }
@@ -27434,7 +27430,6 @@ const UNASSIGNED = "unassigned";
27434
27430
 
27435
27431
  function LocalCommitStatus(props) {
27436
27432
  const argv = Store.useState((state) => state.argv);
27437
- invariant(argv, "argv must exist");
27438
27433
  const fallback = (reactExports.createElement(Text, { color: colors.yellow }, "Fetching PR status from Github..."));
27439
27434
  if (argv["mock-metadata"]) {
27440
27435
  return (reactExports.createElement(Await, { fallback: fallback, function: mock_metadata }, props.children));
@@ -27540,10 +27535,8 @@ async function run$3() {
27540
27535
  const master_branch = state.master_branch;
27541
27536
  const cwd = state.cwd;
27542
27537
  const repo_root = state.repo_root;
27543
- invariant(argv, "argv must exist");
27544
27538
  invariant(branch_name, "branch_name must exist");
27545
27539
  invariant(commit_range, "commit_range must exist");
27546
- invariant(cwd, "cwd must exist");
27547
27540
  invariant(repo_root, "repo_root must exist");
27548
27541
  // always listen for SIGINT event and restore git state
27549
27542
  process.once("SIGINT", handle_exit);
@@ -27653,7 +27646,6 @@ async function run$3() {
27653
27646
  }
27654
27647
  }
27655
27648
  // restore back to original dir
27656
- invariant(cwd, "cwd must exist");
27657
27649
  if (fs.existsSync(cwd)) {
27658
27650
  process.chdir(cwd);
27659
27651
  }
@@ -27824,10 +27816,10 @@ const RE = {
27824
27816
  })),
27825
27817
  };
27826
27818
 
27827
- function ManualRebase(props) {
27828
- return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits..."), function: () => run$2(props) }));
27819
+ function ManualRebase() {
27820
+ return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits..."), function: run$2 }));
27829
27821
  }
27830
- async function run$2(props) {
27822
+ async function run$2() {
27831
27823
  const state = Store.getState();
27832
27824
  const actions = state.actions;
27833
27825
  const argv = state.argv;
@@ -27836,10 +27828,8 @@ async function run$2(props) {
27836
27828
  const master_branch = state.master_branch;
27837
27829
  const cwd = state.cwd;
27838
27830
  const repo_root = state.repo_root;
27839
- invariant(argv, "argv must exist");
27840
27831
  invariant(branch_name, "branch_name must exist");
27841
27832
  invariant(commit_map, "commit_map must exist");
27842
- invariant(cwd, "cwd must exist");
27843
27833
  invariant(repo_root, "repo_root must exist");
27844
27834
  // always listen for SIGINT event and restore git state
27845
27835
  process.once("SIGINT", handle_exit);
@@ -27896,7 +27886,6 @@ async function run$2(props) {
27896
27886
  handle_exit();
27897
27887
  }
27898
27888
  async function rebase_git_revise() {
27899
- invariant(argv, "argv must exist");
27900
27889
  actions.debug(`rebase_git_revise`);
27901
27890
  actions.output(reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }, "Rebasing\u2026"));
27902
27891
  // generate temporary directory and drop sequence editor script
@@ -27990,7 +27979,6 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
27990
27979
  await update_pr_tables(pr_url_list);
27991
27980
  }
27992
27981
  async function rebase_cherry_pick() {
27993
- invariant(argv, "argv must exist");
27994
27982
  actions.debug("rebase_cherry_pick");
27995
27983
  // create temporary branch based on merge base
27996
27984
  await cli(`git checkout -b ${temp_branch_name} ${rebase_merge_base}`);
@@ -28024,11 +28012,10 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28024
28012
  await update_pr_tables(pr_url_list);
28025
28013
  }
28026
28014
  async function sync_group_github(args) {
28027
- if (props.skipSync) {
28015
+ if (!argv.sync) {
28028
28016
  return;
28029
28017
  }
28030
28018
  const { group, pr_url_list } = args;
28031
- invariant(argv, "argv must exist");
28032
28019
  invariant(group.base, "group.base must exist");
28033
28020
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Syncing {group}\u2026", values: {
28034
28021
  group: (reactExports.createElement(Brackets, null, group.pr?.title || group.title || group.id)),
@@ -28130,7 +28117,6 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
28130
28117
  }
28131
28118
  }
28132
28119
  // restore back to original dir
28133
- invariant(cwd, "cwd must exist");
28134
28120
  if (fs.existsSync(cwd)) {
28135
28121
  process.chdir(cwd);
28136
28122
  }
@@ -28329,8 +28315,6 @@ function get_status_bold(row) {
28329
28315
  }
28330
28316
 
28331
28317
  function PostRebaseStatus() {
28332
- const argv = Store.useState((state) => state.argv);
28333
- invariant(argv, "argv must exist");
28334
28318
  return reactExports.createElement(Await, { fallback: null, function: run$1 });
28335
28319
  }
28336
28320
  async function run$1() {
@@ -28348,7 +28332,6 @@ async function run$1() {
28348
28332
  function PreLocalMergeRebase() {
28349
28333
  const actions = Store.useActions();
28350
28334
  const argv = Store.useState((state) => state.argv);
28351
- invariant(argv, "argv must exist");
28352
28335
  reactExports.useEffect(() => {
28353
28336
  if (argv.force) {
28354
28337
  Store.setState((state) => {
@@ -28366,7 +28349,6 @@ function PreLocalMergeRebase() {
28366
28349
  function PreSelectCommitRanges() {
28367
28350
  const actions = Store.useActions();
28368
28351
  const argv = Store.useState((state) => state.argv);
28369
- invariant(argv, "argv must exist");
28370
28352
  reactExports.useEffect(() => {
28371
28353
  if (argv.force) {
28372
28354
  Store.setState((state) => {
@@ -28659,7 +28641,6 @@ function SelectCommitRangesInternal(props) {
28659
28641
  switch (inputLower) {
28660
28642
  case "s":
28661
28643
  state.step = "manual-rebase";
28662
- // state.step = "manual-rebase-no-sync";
28663
28644
  break;
28664
28645
  }
28665
28646
  });
@@ -28766,7 +28747,7 @@ function SelectCommitRangesInternal(props) {
28766
28747
  enter: (reactExports.createElement(Text, { bold: true, color: colors.green }, SYMBOL.enter)),
28767
28748
  } }))));
28768
28749
  function submit_group_input(title) {
28769
- const id = short_id();
28750
+ const id = `gs-${short_id()}`;
28770
28751
  actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { dimColor: true }), message: "Created new group {group} {note}", values: {
28771
28752
  group: reactExports.createElement(Brackets, null, title),
28772
28753
  note: reactExports.createElement(Parens, null, id),
@@ -28784,12 +28765,12 @@ const SYMBOL = {
28784
28765
  };
28785
28766
 
28786
28767
  function Status() {
28787
- const argv = Store.useState((state) => state.argv);
28788
- invariant(argv, "argv must exist");
28789
- return reactExports.createElement(Await, { fallback: null, function: () => run({ argv }) });
28768
+ return reactExports.createElement(Await, { fallback: null, function: run });
28790
28769
  }
28791
- async function run(args) {
28792
- const actions = Store.getState().actions;
28770
+ async function run() {
28771
+ const state = Store.getState();
28772
+ const actions = state.actions;
28773
+ const argv = state.argv;
28793
28774
  const commit_range = Store.getState().commit_range;
28794
28775
  invariant(commit_range, "commit_range must exist");
28795
28776
  actions.output(reactExports.createElement(StatusTable, null));
@@ -28810,7 +28791,7 @@ async function run(args) {
28810
28791
  needs_rebase = true;
28811
28792
  }
28812
28793
  }
28813
- if (args.argv.check) {
28794
+ if (argv.check) {
28814
28795
  actions.exit(0);
28815
28796
  }
28816
28797
  else if (needs_rebase) {
@@ -28823,7 +28804,7 @@ async function run(args) {
28823
28804
  state.step = "pre-select-commit-ranges";
28824
28805
  });
28825
28806
  }
28826
- else if (args.argv.force) {
28807
+ else if (argv.force) {
28827
28808
  Store.setState((state) => {
28828
28809
  state.step = "select-commit-ranges";
28829
28810
  });
@@ -28841,10 +28822,10 @@ async function run(args) {
28841
28822
  function Main() {
28842
28823
  const step = Store.useState((state) => state.step);
28843
28824
  switch (step) {
28844
- case "github-api-error":
28845
- return reactExports.createElement(GithubApiError, null);
28846
28825
  case "loading":
28847
28826
  return null;
28827
+ case "github-api-error":
28828
+ return reactExports.createElement(GithubApiError, null);
28848
28829
  case "status":
28849
28830
  return reactExports.createElement(Status, null);
28850
28831
  case "local-merge-rebase":
@@ -28857,8 +28838,6 @@ function Main() {
28857
28838
  return reactExports.createElement(SelectCommitRanges, null);
28858
28839
  case "manual-rebase":
28859
28840
  return reactExports.createElement(ManualRebase, null);
28860
- case "manual-rebase-no-sync":
28861
- return reactExports.createElement(ManualRebase, { skipSync: true });
28862
28841
  case "post-rebase-status":
28863
28842
  return reactExports.createElement(PostRebaseStatus, null);
28864
28843
  default:
@@ -28893,8 +28872,6 @@ function reducer(state, patch) {
28893
28872
  }
28894
28873
  function RebaseCheck(props) {
28895
28874
  const actions = Store.useActions();
28896
- const argv = Store.useState((state) => state.argv);
28897
- invariant(argv, "argv must exist");
28898
28875
  const [state, patch] = reactExports.useReducer(reducer, {
28899
28876
  status: "init",
28900
28877
  });
@@ -28913,8 +28890,6 @@ function RebaseCheck(props) {
28913
28890
  }
28914
28891
  async function rebase_check() {
28915
28892
  const actions = Store.getState().actions;
28916
- const argv = Store.getState().argv;
28917
- invariant(argv, "argv must exist");
28918
28893
  try {
28919
28894
  const repo_root = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
28920
28895
  let is_rebase = false;
@@ -34283,12 +34258,18 @@ async function command() {
34283
34258
  type: "boolean",
34284
34259
  alias: ["c"],
34285
34260
  default: false,
34286
- description: "Print status table without syncing",
34261
+ description: "Print status table and exit without syncing",
34262
+ })
34263
+ .option("sync", {
34264
+ type: "boolean",
34265
+ alias: ["s"],
34266
+ default: true,
34267
+ description: "Sync commit ranges to Github, disable with --no-sync",
34287
34268
  })
34288
34269
  .option("verify", {
34289
34270
  type: "boolean",
34290
34271
  default: true,
34291
- description: "Skip git hooks such as pre-commit and pre-push",
34272
+ description: "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
34292
34273
  })
34293
34274
  .option("rebase", {
34294
34275
  type: "string",
@@ -34335,7 +34316,7 @@ async function command() {
34335
34316
  .wrap(123)
34336
34317
  // disallow unknown options
34337
34318
  .strict()
34338
- .version("1.2.6" )
34319
+ .version("1.3.0" )
34339
34320
  .showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
34340
34321
  .help("help", "Show usage via `git stack help`").argv);
34341
34322
  }
@@ -34352,6 +34333,7 @@ command()
34352
34333
  state.argv = argv;
34353
34334
  state.cwd = process.cwd();
34354
34335
  });
34336
+ Store.getState().actions.debug(JSON.stringify(argv, null, 2));
34355
34337
  })
34356
34338
  // eslint-disable-next-line no-console
34357
34339
  .catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "1.2.6",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
package/src/app/Debug.tsx CHANGED
@@ -7,7 +7,6 @@ import * as Ink from "ink-cjs";
7
7
 
8
8
  import { Store } from "~/app/Store";
9
9
  import { colors } from "~/core/colors";
10
- import { invariant } from "~/core/invariant";
11
10
  import * as json from "~/core/json";
12
11
 
13
12
  export function Debug() {
@@ -29,8 +28,6 @@ export function Debug() {
29
28
 
30
29
  React.useEffect(
31
30
  function syncStateJson() {
32
- invariant(state.cwd, "state.cwd must exist");
33
-
34
31
  if (!argv?.["write-state-json"]) {
35
32
  return;
36
33
  }
@@ -8,7 +8,6 @@ import { FormatText } from "~/app/FormatText";
8
8
  import { Store } from "~/app/Store";
9
9
  import { cli } from "~/core/cli";
10
10
  import { colors } from "~/core/colors";
11
- import { invariant } from "~/core/invariant";
12
11
  import { match_group } from "~/core/match_group";
13
12
 
14
13
  type Props = {
@@ -16,9 +15,6 @@ type Props = {
16
15
  };
17
16
 
18
17
  export function GatherMetadata(props: Props) {
19
- const argv = Store.useState((state) => state.argv);
20
- invariant(argv, "argv must exist");
21
-
22
18
  const fallback = (
23
19
  <Ink.Text color={colors.yellow}>
24
20
  Gathering local git information...
@@ -36,8 +32,6 @@ async function gather_metadata() {
36
32
  const actions = Store.getState().actions;
37
33
  const argv = Store.getState().argv;
38
34
 
39
- invariant(argv, "argv must exist");
40
-
41
35
  try {
42
36
  // default to master branch, fallback to main
43
37
  let master_branch: string;
@@ -9,12 +9,8 @@ import { Store } from "~/app/Store";
9
9
  import { cli } from "~/core/cli";
10
10
  import { colors } from "~/core/colors";
11
11
  import * as date from "~/core/date";
12
- import { invariant } from "~/core/invariant";
13
12
 
14
13
  export function GithubApiError() {
15
- const argv = Store.useState((state) => state.argv);
16
- invariant(argv, "argv must exist");
17
-
18
14
  return <Await fallback={null} function={run} />;
19
15
  }
20
16
 
@@ -6,7 +6,6 @@ import { Await } from "~/app/Await";
6
6
  import { Store } from "~/app/Store";
7
7
  import * as CommitMetadata from "~/core/CommitMetadata";
8
8
  import { colors } from "~/core/colors";
9
- import { invariant } from "~/core/invariant";
10
9
  import * as json from "~/core/json";
11
10
 
12
11
  type Props = {
@@ -15,7 +14,6 @@ type Props = {
15
14
 
16
15
  export function LocalCommitStatus(props: Props) {
17
16
  const argv = Store.useState((state) => state.argv);
18
- invariant(argv, "argv must exist");
19
17
 
20
18
  const fallback = (
21
19
  <Ink.Text color={colors.yellow}>Fetching PR status from Github...</Ink.Text>
@@ -35,10 +35,8 @@ async function run() {
35
35
  const cwd = state.cwd;
36
36
  const repo_root = state.repo_root;
37
37
 
38
- invariant(argv, "argv must exist");
39
38
  invariant(branch_name, "branch_name must exist");
40
39
  invariant(commit_range, "commit_range must exist");
41
- invariant(cwd, "cwd must exist");
42
40
  invariant(repo_root, "repo_root must exist");
43
41
 
44
42
  // always listen for SIGINT event and restore git state
@@ -200,7 +198,6 @@ async function run() {
200
198
  }
201
199
 
202
200
  // restore back to original dir
203
- invariant(cwd, "cwd must exist");
204
201
  if (fs.existsSync(cwd)) {
205
202
  process.chdir(cwd);
206
203
  }
package/src/app/Main.tsx CHANGED
@@ -15,12 +15,12 @@ export function Main() {
15
15
  const step = Store.useState((state) => state.step);
16
16
 
17
17
  switch (step) {
18
- case "github-api-error":
19
- return <GithubApiError />;
20
-
21
18
  case "loading":
22
19
  return null;
23
20
 
21
+ case "github-api-error":
22
+ return <GithubApiError />;
23
+
24
24
  case "status":
25
25
  return <Status />;
26
26
 
@@ -39,9 +39,6 @@ export function Main() {
39
39
  case "manual-rebase":
40
40
  return <ManualRebase />;
41
41
 
42
- case "manual-rebase-no-sync":
43
- return <ManualRebase skipSync />;
44
-
45
42
  case "post-rebase-status":
46
43
  return <PostRebaseStatus />;
47
44
 
@@ -20,20 +20,16 @@ import * as github from "~/core/github";
20
20
  import { invariant } from "~/core/invariant";
21
21
  import { short_id } from "~/core/short_id";
22
22
 
23
- type Props = {
24
- skipSync?: boolean;
25
- };
26
-
27
- export function ManualRebase(props: Props) {
23
+ export function ManualRebase() {
28
24
  return (
29
25
  <Await
30
26
  fallback={<Ink.Text color={colors.yellow}>Rebasing commits...</Ink.Text>}
31
- function={() => run(props)}
27
+ function={run}
32
28
  />
33
29
  );
34
30
  }
35
31
 
36
- async function run(props: Props) {
32
+ async function run() {
37
33
  const state = Store.getState();
38
34
  const actions = state.actions;
39
35
  const argv = state.argv;
@@ -43,10 +39,8 @@ async function run(props: Props) {
43
39
  const cwd = state.cwd;
44
40
  const repo_root = state.repo_root;
45
41
 
46
- invariant(argv, "argv must exist");
47
42
  invariant(branch_name, "branch_name must exist");
48
43
  invariant(commit_map, "commit_map must exist");
49
- invariant(cwd, "cwd must exist");
50
44
  invariant(repo_root, "repo_root must exist");
51
45
 
52
46
  // always listen for SIGINT event and restore git state
@@ -120,8 +114,6 @@ async function run(props: Props) {
120
114
  }
121
115
 
122
116
  async function rebase_git_revise() {
123
- invariant(argv, "argv must exist");
124
-
125
117
  actions.debug(`rebase_git_revise`);
126
118
 
127
119
  actions.output(
@@ -212,8 +204,6 @@ async function run(props: Props) {
212
204
  }
213
205
 
214
206
  async function rebase_cherry_pick() {
215
- invariant(argv, "argv must exist");
216
-
217
207
  actions.debug("rebase_cherry_pick");
218
208
 
219
209
  // create temporary branch based on merge base
@@ -273,13 +263,12 @@ async function run(props: Props) {
273
263
  pr_url_list: Array<string>;
274
264
  skip_checkout: boolean;
275
265
  }) {
276
- if (props.skipSync) {
266
+ if (!argv.sync) {
277
267
  return;
278
268
  }
279
269
 
280
270
  const { group, pr_url_list } = args;
281
271
 
282
- invariant(argv, "argv must exist");
283
272
  invariant(group.base, "group.base must exist");
284
273
 
285
274
  actions.output(
@@ -412,7 +401,6 @@ async function run(props: Props) {
412
401
  }
413
402
 
414
403
  // restore back to original dir
415
- invariant(cwd, "cwd must exist");
416
404
  if (fs.existsSync(cwd)) {
417
405
  process.chdir(cwd);
418
406
  }
@@ -6,12 +6,8 @@ import { Await } from "~/app/Await";
6
6
  import { StatusTable } from "~/app/StatusTable";
7
7
  import { Store } from "~/app/Store";
8
8
  import * as CommitMetadata from "~/core/CommitMetadata";
9
- import { invariant } from "~/core/invariant";
10
9
 
11
10
  export function PostRebaseStatus() {
12
- const argv = Store.useState((state) => state.argv);
13
- invariant(argv, "argv must exist");
14
-
15
11
  return <Await fallback={null} function={run} />;
16
12
  }
17
13
 
@@ -2,12 +2,10 @@ import * as React from "react";
2
2
 
3
3
  import { Store } from "~/app/Store";
4
4
  import { YesNoPrompt } from "~/app/YesNoPrompt";
5
- import { invariant } from "~/core/invariant";
6
5
 
7
6
  export function PreLocalMergeRebase() {
8
7
  const actions = Store.useActions();
9
8
  const argv = Store.useState((state) => state.argv);
10
- invariant(argv, "argv must exist");
11
9
 
12
10
  React.useEffect(() => {
13
11
  if (argv.force) {
@@ -2,12 +2,10 @@ import * as React from "react";
2
2
 
3
3
  import { Store } from "~/app/Store";
4
4
  import { YesNoPrompt } from "~/app/YesNoPrompt";
5
- import { invariant } from "~/core/invariant";
6
5
 
7
6
  export function PreSelectCommitRanges() {
8
7
  const actions = Store.useActions();
9
8
  const argv = Store.useState((state) => state.argv);
10
- invariant(argv, "argv must exist");
11
9
 
12
10
  React.useEffect(() => {
13
11
  if (argv.force) {
@@ -10,7 +10,6 @@ import { Store } from "~/app/Store";
10
10
  import { YesNoPrompt } from "~/app/YesNoPrompt";
11
11
  import { cli } from "~/core/cli";
12
12
  import { colors } from "~/core/colors";
13
- import { invariant } from "~/core/invariant";
14
13
 
15
14
  type Props = {
16
15
  children: React.ReactNode;
@@ -26,8 +25,6 @@ function reducer(state: State, patch: Partial<State>) {
26
25
 
27
26
  export function RebaseCheck(props: Props) {
28
27
  const actions = Store.useActions();
29
- const argv = Store.useState((state) => state.argv);
30
- invariant(argv, "argv must exist");
31
28
 
32
29
  const [state, patch] = React.useReducer(reducer, {
33
30
  status: "init",
@@ -68,9 +65,6 @@ export function RebaseCheck(props: Props) {
68
65
 
69
66
  async function rebase_check() {
70
67
  const actions = Store.getState().actions;
71
- const argv = Store.getState().argv;
72
-
73
- invariant(argv, "argv must exist");
74
68
 
75
69
  try {
76
70
  const repo_root = (await cli(`git rev-parse --absolute-git-dir`)).stdout;
@@ -130,7 +130,6 @@ function SelectCommitRangesInternal(props: Props) {
130
130
  switch (inputLower) {
131
131
  case "s":
132
132
  state.step = "manual-rebase";
133
- // state.step = "manual-rebase-no-sync";
134
133
  break;
135
134
  }
136
135
  });
@@ -346,7 +345,7 @@ function SelectCommitRangesInternal(props: Props) {
346
345
  );
347
346
 
348
347
  function submit_group_input(title: string) {
349
- const id = short_id();
348
+ const id = `gs-${short_id()}`;
350
349
 
351
350
  actions.output(
352
351
  <FormatText
@@ -8,21 +8,15 @@ import { Store } from "~/app/Store";
8
8
  import { colors } from "~/core/colors";
9
9
  import { invariant } from "~/core/invariant";
10
10
 
11
- import type { Argv } from "~/command";
12
-
13
11
  export function Status() {
14
- const argv = Store.useState((state) => state.argv);
15
- invariant(argv, "argv must exist");
16
-
17
- return <Await fallback={null} function={() => run({ argv })} />;
12
+ return <Await fallback={null} function={run} />;
18
13
  }
19
14
 
20
- type Args = {
21
- argv: Argv;
22
- };
15
+ async function run() {
16
+ const state = Store.getState();
17
+ const actions = state.actions;
18
+ const argv = state.argv;
23
19
 
24
- async function run(args: Args) {
25
- const actions = Store.getState().actions;
26
20
  const commit_range = Store.getState().commit_range;
27
21
 
28
22
  invariant(commit_range, "commit_range must exist");
@@ -51,7 +45,7 @@ async function run(args: Args) {
51
45
  }
52
46
  }
53
47
 
54
- if (args.argv.check) {
48
+ if (argv.check) {
55
49
  actions.exit(0);
56
50
  } else if (needs_rebase) {
57
51
  Store.setState((state) => {
@@ -61,7 +55,7 @@ async function run(args: Args) {
61
55
  Store.setState((state) => {
62
56
  state.step = "pre-select-commit-ranges";
63
57
  });
64
- } else if (args.argv.force) {
58
+ } else if (argv.force) {
65
59
  Store.setState((state) => {
66
60
  state.step = "select-commit-ranges";
67
61
  });
package/src/app/Store.tsx CHANGED
@@ -25,10 +25,11 @@ type MutateOutputArgs = {
25
25
  };
26
26
 
27
27
  export type State = {
28
- argv: null | Argv;
29
- ink: null | InkInstance;
28
+ // set immediately in `index.tsx` so no `null` scenario
29
+ argv: Argv;
30
+ ink: InkInstance;
31
+ cwd: string;
30
32
 
31
- cwd: null | string;
32
33
  username: null | string;
33
34
  repo_path: null | string;
34
35
  repo_root: null | string;
@@ -47,7 +48,6 @@ export type State = {
47
48
  | "pre-select-commit-ranges"
48
49
  | "select-commit-ranges"
49
50
  | "manual-rebase"
50
- | "manual-rebase-no-sync"
51
51
  | "post-rebase-status";
52
52
 
53
53
  output: Array<React.ReactNode>;
@@ -85,10 +85,11 @@ export type State = {
85
85
 
86
86
  const BaseStore = createStore<State>()(
87
87
  immer((set, get) => ({
88
- argv: null,
89
- ink: null,
88
+ // set immediately in `index.tsx` so no `null` scenario
89
+ argv: {} as Argv,
90
+ ink: {} as InkInstance,
91
+ cwd: "",
90
92
 
91
- cwd: null,
92
93
  username: null,
93
94
  repo_path: null,
94
95
  repo_root: null,
package/src/command.ts CHANGED
@@ -22,13 +22,21 @@ export async function command() {
22
22
  type: "boolean",
23
23
  alias: ["c"],
24
24
  default: false,
25
- description: "Print status table without syncing",
25
+ description: "Print status table and exit without syncing",
26
+ })
27
+
28
+ .option("sync", {
29
+ type: "boolean",
30
+ alias: ["s"],
31
+ default: true,
32
+ description: "Sync commit ranges to Github, disable with --no-sync",
26
33
  })
27
34
 
28
35
  .option("verify", {
29
36
  type: "boolean",
30
37
  default: true,
31
- description: "Skip git hooks such as pre-commit and pre-push",
38
+ description:
39
+ "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
32
40
  })
33
41
 
34
42
  .option("rebase", {
@@ -165,8 +165,9 @@ export async function range(commit_group_map?: CommitGroupMap) {
165
165
  }
166
166
 
167
167
  async function get_commit_list() {
168
+ const master_branch = Store.getState().master_branch;
168
169
  const log_result = await cli(
169
- `git log master..HEAD --oneline --format=%H --color=never`
170
+ `git log ${master_branch}..HEAD --oneline --format=%H --color=never`
170
171
  );
171
172
 
172
173
  if (!log_result.stdout) {
package/src/index.tsx CHANGED
@@ -17,6 +17,8 @@ command()
17
17
  state.argv = argv;
18
18
  state.cwd = process.cwd();
19
19
  });
20
+
21
+ Store.getState().actions.debug(JSON.stringify(argv, null, 2));
20
22
  })
21
23
  // eslint-disable-next-line no-console
22
24
  .catch(console.error);