git-stack-cli 0.8.0 → 0.8.2

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.
Files changed (46) hide show
  1. package/dist/app/LocalMergeRebase.js +2 -1
  2. package/dist/app/ManualRebase.js +5 -1
  3. package/dist/app/MultiSelect.js +1 -1
  4. package/dist/core/cli.js +1 -1
  5. package/package.json +1 -1
  6. package/dist/__fixtures__/metadata.json +0 -186
  7. package/dist/app/App copy.js +0 -30
  8. package/dist/app/ArgCheck.js +0 -21
  9. package/dist/app/Brackets copy.js +0 -10
  10. package/dist/app/Counter.js +0 -19
  11. package/dist/app/GatherMetadata copy.js +0 -91
  12. package/dist/app/InitMetadata.js +0 -14
  13. package/dist/app/Input.js +0 -15
  14. package/dist/app/KeepAlive.js +0 -11
  15. package/dist/app/Main copy.js +0 -200
  16. package/dist/app/ManualRebase copy.js +0 -127
  17. package/dist/app/MultiSelect copy.js +0 -76
  18. package/dist/app/NPMAutoUpdate.js +0 -34
  19. package/dist/app/Parens copy.js +0 -9
  20. package/dist/app/PostRebaseStatus copy.js +0 -23
  21. package/dist/app/PreSelectCommitRanges copy.js +0 -21
  22. package/dist/app/SelectCommitRange.js +0 -1
  23. package/dist/app/Status copy.js +0 -46
  24. package/dist/app/Url copy.js +0 -6
  25. package/dist/app/YesNoPrompt copy.js +0 -24
  26. package/dist/cli.js +0 -9
  27. package/dist/core/Metadata copy.js +0 -37
  28. package/dist/core/StackTable.js +0 -38
  29. package/dist/core/SummaryTable.js +0 -38
  30. package/dist/core/ZustandStore.js +0 -23
  31. package/dist/core/cli copy.js +0 -44
  32. package/dist/core/color.js +0 -83
  33. package/dist/core/dependency_check.js +0 -27
  34. package/dist/core/exit.js +0 -4
  35. package/dist/core/get_commit_metadata.js +0 -61
  36. package/dist/core/id.js +0 -61
  37. package/dist/core/invariant copy.js +0 -5
  38. package/dist/core/isFiniteValue.js +0 -3
  39. package/dist/core/is_dev.js +0 -1
  40. package/dist/core/readJson.js +0 -3
  41. package/dist/core/serialize_json.js +0 -17
  42. package/dist/core/sleep copy.js +0 -3
  43. package/dist/main copy.js +0 -266
  44. package/dist/main.backup.js +0 -266
  45. package/dist/main.js +0 -265
  46. /package/dist/app/{main.js → Main.js} +0 -0
@@ -108,9 +108,10 @@ async function run() {
108
108
  const spawn_options = { ignoreExitCode: true };
109
109
  // always clean up any patch files
110
110
  cli.sync(`rm ${PATCH_FILE}`, spawn_options);
111
- // always hard reset to allow subsequent checkout
111
+ // always hard reset and clean to allow subsequent checkout
112
112
  // if there are files checkout will fail and cascade fail subsequent commands
113
113
  cli.sync(`git reset --hard`, spawn_options);
114
+ cli.sync(`git clean -df`, spawn_options);
114
115
  // always put self back in original branch
115
116
  cli.sync(`git checkout ${branch_name}`, spawn_options);
116
117
  // ...and cleanup temporary branch
@@ -54,6 +54,9 @@ async function run(props) {
54
54
  for (let i = rebase_group_index; i < commit_range.group_list.length; i++) {
55
55
  const group = commit_range.group_list[i];
56
56
  invariant(group.base, "group.base must exist");
57
+ actions.output(React.createElement(FormatText, { wrapper: React.createElement(Ink.Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Rebasing {group}\u2026", values: {
58
+ group: (React.createElement(Brackets, null, group.pr?.title || group.title || group.id)),
59
+ } }));
57
60
  const selected_url = get_group_url(group);
58
61
  // cherry-pick and amend commits one by one
59
62
  for (const commit of group.commits) {
@@ -167,9 +170,10 @@ async function run(props) {
167
170
  const spawn_options = { ignoreExitCode: true };
168
171
  // always clean up any patch files
169
172
  cli.sync(`rm ${PATCH_FILE}`, spawn_options);
170
- // always hard reset to allow subsequent checkout
173
+ // always hard reset and clean to allow subsequent checkout
171
174
  // if there are files checkout will fail and cascade fail subsequent commands
172
175
  cli.sync(`git reset --hard`, spawn_options);
176
+ cli.sync(`git clean -df`, spawn_options);
173
177
  // always put self back in original branch
174
178
  cli.sync(`git checkout ${branch_name}`, spawn_options);
175
179
  // ...and cleanup temporary branch
@@ -94,7 +94,7 @@ export function MultiSelect(props) {
94
94
  const active = i === index;
95
95
  const selected = selected_set.has(i);
96
96
  const disabled = item.disabled || false;
97
- return (React.createElement(ItemRow, { key: item.label, label: item.label, active: active, selected: selected, disabled: disabled, maxWidth: props.maxWidth }));
97
+ return (React.createElement(ItemRow, { key: i, label: item.label, active: active, selected: selected, disabled: disabled, maxWidth: props.maxWidth }));
98
98
  })));
99
99
  }
100
100
  function ItemRow(props) {
package/dist/core/cli.js CHANGED
@@ -18,7 +18,7 @@ export async function cli(unsafe_command, unsafe_options) {
18
18
  let output = "";
19
19
  const id = `${++i}-${command}`;
20
20
  state.actions.debug(`[start] ${command}`);
21
- state.actions.debug(`[start] ${command}\n`, id);
21
+ state.actions.debug(`[] ${command}\n`, id);
22
22
  function write_output(value) {
23
23
  output += value;
24
24
  state.actions.debug(value, id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-stack-cli",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "",
5
5
  "author": "magus",
6
6
  "license": "MIT",
@@ -1,186 +0,0 @@
1
- {
2
- "head": "cc09b96b823d9dde77188e675d3090be7c1d625a",
3
- "merge_base": "9528176b12abf81c779bc5244afc7d760f6fa422",
4
- "branch_name": "dev/noah/a-test",
5
- "commit_range": {
6
- "invalid": true,
7
- "group_map": {},
8
- "commit_list": [
9
- {
10
- "sha": "a28f1ef080b56b56699bc420b200968e793702a9",
11
- "message": "more remove",
12
- "raw_message": "more remove\n\ngit-multi-diff-id: 14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
13
- "pr": {
14
- "baseRefName": "master",
15
- "commits": [
16
- {
17
- "authoredDate": "2023-10-22T23:13:20Z",
18
- "authors": [
19
- {
20
- "email": "noah@iamnoah.com",
21
- "id": "MDQ6VXNlcjI5MDA4NA==",
22
- "login": "magus",
23
- "name": "magus"
24
- }
25
- ],
26
- "committedDate": "2023-10-28T19:16:29Z",
27
- "messageBody": "git-multi-diff-id: 14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
28
- "messageHeadline": "more remove",
29
- "oid": "a28f1ef080b56b56699bc420b200968e793702a9"
30
- }
31
- ],
32
- "headRefName": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
33
- "number": 28,
34
- "state": "OPEN",
35
- "title": "more remove",
36
- "url": "https://github.com/magus/git-multi-diff-playground/pull/28"
37
- },
38
- "metadata": {
39
- "id": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6"
40
- }
41
- },
42
- {
43
- "sha": "7454ce81940f2a0964ff06c7a98c7fa1892f82bf",
44
- "message": "remove num",
45
- "raw_message": "remove num\n\ngit-multi-diff-id: 3d1d890d-11c9-4569-83c3-e3aff6426e37",
46
- "pr": {
47
- "baseRefName": "14e097a1-fa9b-45af-8f7d-b77df9d91fe6",
48
- "commits": [
49
- {
50
- "authoredDate": "2023-10-22T23:13:14Z",
51
- "authors": [
52
- {
53
- "email": "noah@iamnoah.com",
54
- "id": "MDQ6VXNlcjI5MDA4NA==",
55
- "login": "magus",
56
- "name": "magus"
57
- }
58
- ],
59
- "committedDate": "2023-10-28T19:16:33Z",
60
- "messageBody": "git-multi-diff-id: 3d1d890d-11c9-4569-83c3-e3aff6426e37",
61
- "messageHeadline": "remove num",
62
- "oid": "7454ce81940f2a0964ff06c7a98c7fa1892f82bf"
63
- }
64
- ],
65
- "headRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
66
- "number": 27,
67
- "state": "OPEN",
68
- "title": "remove num",
69
- "url": "https://github.com/magus/git-multi-diff-playground/pull/27"
70
- },
71
- "metadata": {
72
- "id": "3d1d890d-11c9-4569-83c3-e3aff6426e37"
73
- }
74
- },
75
- {
76
- "sha": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0",
77
- "message": "strawberry",
78
- "raw_message": "strawberry\n\ngit-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
79
- "pr": {
80
- "baseRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
81
- "commits": [
82
- {
83
- "authoredDate": "2023-10-25T09:29:30Z",
84
- "authors": [
85
- {
86
- "email": "noah@iamnoah.com",
87
- "id": "MDQ6VXNlcjI5MDA4NA==",
88
- "login": "magus",
89
- "name": "magus"
90
- }
91
- ],
92
- "committedDate": "2023-10-28T19:16:37Z",
93
- "messageBody": "git-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
94
- "messageHeadline": "strawberry",
95
- "oid": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0"
96
- }
97
- ],
98
- "headRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
99
- "number": 30,
100
- "state": "OPEN",
101
- "title": "strawberry",
102
- "url": "https://github.com/magus/git-multi-diff-playground/pull/30"
103
- },
104
- "metadata": {
105
- "id": "53d15f9a-2451-492c-a831-642d41ad3ef4"
106
- }
107
- },
108
- {
109
- "sha": "24fa3301563d40b42f698bff92b8a805412a4a69",
110
- "message": "orange color",
111
- "raw_message": "orange color",
112
- "pr": null,
113
- "metadata": {
114
- "id": null
115
- }
116
- },
117
- {
118
- "sha": "dea1b85bdbcec0b27f1c5b2cc675e47fd9f51005",
119
- "message": "cantaloupe",
120
- "raw_message": "cantaloupe\nline2 changed\nline3 'abc'\nline4\nline5 \"hello world\"\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\ngit-multi-diff-id: 398c0ead-77ad-41a4-af6e-280f99998c28",
121
- "pr": {
122
- "baseRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
123
- "commits": [
124
- {
125
- "authoredDate": "2023-10-22T23:13:35Z",
126
- "authors": [
127
- {
128
- "email": "noah@iamnoah.com",
129
- "id": "MDQ6VXNlcjI5MDA4NA==",
130
- "login": "magus",
131
- "name": "magus"
132
- }
133
- ],
134
- "committedDate": "2023-10-28T19:16:40Z",
135
- "messageBody": "line2 changed\nline3 'abc'\nline4\nline5 \"hello world\"\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\ngit-multi-diff-id: 398c0ead-77ad-41a4-af6e-280f99998c28",
136
- "messageHeadline": "cantaloupe",
137
- "oid": "86d0b3cf5dcbd94963f2839818734c3b0e13d2fc"
138
- }
139
- ],
140
- "headRefName": "398c0ead-77ad-41a4-af6e-280f99998c28",
141
- "number": 29,
142
- "state": "OPEN",
143
- "title": "cantaloupe line2 line3 'abc' line4 line5 \"hello world\" Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
144
- "url": "https://github.com/magus/git-multi-diff-playground/pull/29"
145
- },
146
- "metadata": {
147
- "id": "398c0ead-77ad-41a4-af6e-280f99998c28"
148
- }
149
- },
150
- {
151
- "sha": "cc09b96b823d9dde77188e675d3090be7c1d625a",
152
- "message": "pineapple",
153
- "raw_message": "pineapple\n\ngit-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
154
- "pr": {
155
- "baseRefName": "3d1d890d-11c9-4569-83c3-e3aff6426e37",
156
- "commits": [
157
- {
158
- "authoredDate": "2023-10-25T09:29:30Z",
159
- "authors": [
160
- {
161
- "email": "noah@iamnoah.com",
162
- "id": "MDQ6VXNlcjI5MDA4NA==",
163
- "login": "magus",
164
- "name": "magus"
165
- }
166
- ],
167
- "committedDate": "2023-10-28T19:16:37Z",
168
- "messageBody": "git-multi-diff-id: 53d15f9a-2451-492c-a831-642d41ad3ef4",
169
- "messageHeadline": "strawberry",
170
- "oid": "a339f9cc4d8c10b691fef2c2425bf4a67c8c70f0"
171
- }
172
- ],
173
- "headRefName": "53d15f9a-2451-492c-a831-642d41ad3ef4",
174
- "number": 30,
175
- "state": "OPEN",
176
- "title": "strawberry",
177
- "url": "https://github.com/magus/git-multi-diff-playground/pull/30"
178
- },
179
- "metadata": {
180
- "id": "53d15f9a-2451-492c-a831-642d41ad3ef4"
181
- }
182
- }
183
- ],
184
- "UNASSIGNED": "unassigned"
185
- }
186
- }
@@ -1,30 +0,0 @@
1
- import * as React from "react";
2
- import { Debug } from "./Debug.js";
3
- import { DependencyCheck } from "./DependencyCheck.js";
4
- import { GatherMetadata } from "./GatherMetadata.js";
5
- import { GithubApiError } from "./GithubApiError.js";
6
- import { Main } from "./Main.js";
7
- import { Output } from "./Output.js";
8
- import { Store } from "./Store.js";
9
- export function App() {
10
- const ink = Store.useState((state) => state.ink);
11
- const argv = Store.useState((state) => state.argv);
12
- if (!ink || !argv) {
13
- return null;
14
- }
15
- // // debug component
16
- // return (
17
- // <React.Fragment>
18
- // <Debug />
19
- // <Output />
20
- // <GithubApiError />
21
- // </React.Fragment>
22
- // );
23
- return (React.createElement(Providers, null,
24
- React.createElement(Debug, null),
25
- React.createElement(Output, null),
26
- !argv.debug ? null : React.createElement(GithubApiError, null),
27
- React.createElement(DependencyCheck, null,
28
- React.createElement(GatherMetadata, null,
29
- React.createElement(Main, null)))));
30
- }
@@ -1,21 +0,0 @@
1
- import * as React from "react";
2
- import { invariant } from "../core/invariant.js";
3
- import { GithubApiError } from "./GithubApiError.js";
4
- import { Store } from "./Store.js";
5
- export function ArgCheck(props) {
6
- const argv = Store.useState((state) => state.argv);
7
- invariant(argv, "argv must exist");
8
- // if (argv.debug) {
9
- // return (
10
- // <Await
11
- // fallback={<Ink.Text>Checking Github API quota...</Ink.Text>}
12
- // function={github_quota}
13
- // >
14
- // {props.children}
15
- // </Await>
16
- // );
17
- // }
18
- return (React.createElement(React.Fragment, null,
19
- React.createElement(GithubApiError, null),
20
- props.children));
21
- }
@@ -1,10 +0,0 @@
1
- import * as React from "react";
2
- import * as Ink from "ink";
3
- export function Brackets(props) {
4
- const color = "#f97316";
5
- const text_color = "#06b6d4";
6
- return (React.createElement(Ink.Text, { color: text_color },
7
- React.createElement(Ink.Text, { color: color }, "["),
8
- props.children,
9
- React.createElement(Ink.Text, { color: color }, "]")));
10
- }
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import * as Ink from "ink";
3
- export function Counter() {
4
- const { isFocused } = Ink.useFocus();
5
- const [counter, setCounter] = React.useState(0);
6
- React.useEffect(() => {
7
- const timer = setInterval(() => {
8
- setCounter((prevCounter) => prevCounter + 1);
9
- }, 100);
10
- return () => {
11
- clearInterval(timer);
12
- };
13
- }, []);
14
- return (React.createElement(Ink.Text, { color: "green" },
15
- counter,
16
- " tests passed (focus:",
17
- String(isFocused),
18
- ")"));
19
- }
@@ -1,91 +0,0 @@
1
- import * as React from "react";
2
- import * as Ink from "ink";
3
- import { cli } from "../core/cli.js";
4
- import { colors } from "../core/colors.js";
5
- import { invariant } from "../core/invariant.js";
6
- import { match_group } from "../core/match_group.js";
7
- import { Await } from "./Await.js";
8
- import { Brackets } from "./Brackets.js";
9
- import { FormatText } from "./FormatText.js";
10
- import { Store } from "./Store.js";
11
- export function GatherMetadata(props) {
12
- const argv = Store.useState((state) => state.argv);
13
- invariant(argv, "argv must exist");
14
- const fallback = (React.createElement(Ink.Text, { color: colors.yellow }, "Gathering local git information..."));
15
- return (React.createElement(Await, { fallback: fallback, function: gather_metadata }, props.children));
16
- }
17
- async function gather_metadata() {
18
- const actions = Store.getState().actions;
19
- const argv = Store.getState().argv;
20
- invariant(argv, "argv must exist");
21
- try {
22
- // default to master branch, fallback to main
23
- let master_branch;
24
- if (argv.branch) {
25
- actions.debug(React.createElement(FormatText, { message: "Setting master branch to {branch}", values: {
26
- branch: React.createElement(Brackets, null, argv.branch),
27
- } }));
28
- master_branch = argv.branch;
29
- }
30
- else {
31
- const detect_master = await cli(`git branch --list "${BRANCH.master}" --color=never`);
32
- if (detect_master.stdout !== "") {
33
- master_branch = BRANCH.master;
34
- }
35
- else {
36
- actions.debug(React.createElement(FormatText, { message: "Could not find {master} branch, falling back to {main}", values: {
37
- master: React.createElement(Brackets, null, BRANCH.master),
38
- main: React.createElement(Brackets, null, BRANCH.main),
39
- } }));
40
- master_branch = BRANCH.main;
41
- }
42
- }
43
- const branch_name = (await cli("git rev-parse --abbrev-ref HEAD")).stdout;
44
- // handle when there are no detected changes
45
- if (branch_name === master_branch) {
46
- actions.newline();
47
- actions.error("Must run within a branch.");
48
- actions.exit(0);
49
- return;
50
- }
51
- const head = (await cli("git rev-parse HEAD")).stdout;
52
- const merge_base = (await cli(`git merge-base HEAD ${master_branch}`))
53
- .stdout;
54
- // handle when there are no detected changes
55
- if (head === merge_base) {
56
- actions.newline();
57
- actions.output(React.createElement(Ink.Text, { color: colors.gray }, "No changes detected."));
58
- actions.exit(0);
59
- return;
60
- }
61
- // git@github.com:magus/git-multi-diff-playground.git
62
- // https://github.com/magus/git-multi-diff-playground.git
63
- const origin_url = (await cli(`git config --get remote.origin.url`)).stdout;
64
- const repo_path = match_group(origin_url, RE.repo_path, "repo_path");
65
- Store.setState((state) => {
66
- state.repo_path = repo_path;
67
- state.master_branch = master_branch;
68
- state.head = head;
69
- state.merge_base = merge_base;
70
- state.branch_name = branch_name;
71
- });
72
- }
73
- catch (err) {
74
- actions.error("Unable to gather git metadata.");
75
- if (err instanceof Error) {
76
- if (actions.isDebug()) {
77
- actions.error(err.message);
78
- }
79
- }
80
- actions.exit(7);
81
- }
82
- }
83
- const RE = {
84
- // git@github.com:magus/git-multi-diff-playground.git
85
- // https://github.com/magus/git-multi-diff-playground.git
86
- repo_path: /(?<repo_path>[^:^/]+\/[^/]+)\.git/,
87
- };
88
- const BRANCH = {
89
- master: "master",
90
- main: "main",
91
- };
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- import { cli } from "../core/cli.js";
3
- import { Await } from "./Await.js";
4
- import { Store } from "./Store.js";
5
- export function InitMetadata() {
6
- return (React.createElement(Await, { function: async () => {
7
- const head = (await cli("git rev-parse HEAD")).stdout;
8
- const merge_base = (await cli("git merge-base HEAD master")).stdout;
9
- Store.setState((state) => {
10
- state.head = head;
11
- state.merge_base = merge_base;
12
- });
13
- } }));
14
- }
package/dist/app/Input.js DELETED
@@ -1,15 +0,0 @@
1
- import * as React from "react";
2
- import * as Ink from "ink";
3
- export function Input(props) {
4
- const [value, set_value] = React.useState(props.value || "");
5
- Ink.useInput((input, key) => {
6
- if (key.backspace) {
7
- set_value((value) => value.slice(0, -1));
8
- }
9
- else {
10
- set_value((value) => `${value}${input}`);
11
- }
12
- });
13
- return (React.createElement(Ink.Box, { borderStyle: "single" },
14
- React.createElement(Ink.Text, null, value)));
15
- }
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- export function KeepAlive() {
3
- // Exit the app after 5 seconds
4
- React.useEffect(() => {
5
- const timer = setInterval(() => { }, 5 * 1000);
6
- return function cleanup() {
7
- clearInterval(timer);
8
- };
9
- }, []);
10
- return null;
11
- }