git-stack-cli 2.2.7 → 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 +424 -433
- package/package.json +1 -1
- package/scripts/release-brew.ts +2 -0
- package/src/app/CherryPickCheck.tsx +9 -8
- package/src/app/DetectInitialPR.tsx +1 -5
- package/src/app/DirtyCheck.tsx +1 -5
- package/src/app/GatherMetadata.tsx +1 -3
- package/src/app/LocalCommitStatus.tsx +1 -3
- package/src/app/ManualRebase.tsx +0 -1
- package/src/app/RebaseCheck.tsx +1 -5
- package/src/app/SyncGithub.tsx +0 -1
- package/src/app/VerboseDebugInfo.tsx +1 -3
- package/src/command.ts +1 -0
- package/src/commands/Rebase.tsx +39 -42
- package/src/core/cli.ts +8 -1
package/package.json
CHANGED
package/scripts/release-brew.ts
CHANGED
|
@@ -66,6 +66,8 @@ const re_token = (name: string) => new RegExp(`{{ ${name} }}`, "g");
|
|
|
66
66
|
process.chdir(HOMEBREW_DIR);
|
|
67
67
|
await spawn.sync(`git reset --hard`);
|
|
68
68
|
await spawn.sync(`git checkout master`);
|
|
69
|
+
await spawn.sync("git fetch --prune");
|
|
70
|
+
await spawn.sync("git reset --hard origin/master");
|
|
69
71
|
|
|
70
72
|
// homebrew tap formula (binaries)
|
|
71
73
|
|
|
@@ -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
|
-
|
|
76
|
+
if (await safe_exists(cherry_pick_file)) {
|
|
77
|
+
return patch({ status: "prompt" });
|
|
78
|
+
}
|
|
77
79
|
|
|
78
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
actions.error(err.message);
|
|
138
|
-
}
|
|
134
|
+
actions.error(err.message);
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
actions.exit(9);
|
package/src/app/DirtyCheck.tsx
CHANGED
|
@@ -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
|
-
|
|
119
|
-
actions.error(err.message);
|
|
120
|
-
}
|
|
116
|
+
actions.error(err.message);
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
actions.exit(12);
|
package/src/app/ManualRebase.tsx
CHANGED
package/src/app/RebaseCheck.tsx
CHANGED
|
@@ -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
|
-
|
|
86
|
-
actions.error(err.message);
|
|
87
|
-
}
|
|
83
|
+
actions.error(err.message);
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
actions.exit(13);
|
package/src/app/SyncGithub.tsx
CHANGED
package/src/command.ts
CHANGED
|
@@ -9,6 +9,7 @@ export async function command() {
|
|
|
9
9
|
// https://yargs.js.org/docs/#api-reference-optionkey-opt
|
|
10
10
|
return (
|
|
11
11
|
yargs(hideBin(process.argv))
|
|
12
|
+
.scriptName("git stack")
|
|
12
13
|
.usage("Usage: git stack [command] [options]")
|
|
13
14
|
|
|
14
15
|
.command("$0", "Sync commit ranges to Github", (yargs) => yargs.options(DefaultOptions))
|
package/src/commands/Rebase.tsx
CHANGED
|
@@ -7,7 +7,7 @@ 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 {
|
|
10
|
+
import { Status } from "~/app/Status";
|
|
11
11
|
import { Store } from "~/app/Store";
|
|
12
12
|
import * as CommitMetadata from "~/core/CommitMetadata";
|
|
13
13
|
import { cli } from "~/core/cli";
|
|
@@ -71,36 +71,33 @@ Rebase.run = async function run() {
|
|
|
71
71
|
|
|
72
72
|
// drop commits that are in groups of merged PRs
|
|
73
73
|
const merged_pr = commit_pr?.state === "MERGED";
|
|
74
|
+
const commit_message = <Ink.Text color={colors.blue}>{commit.subject_line}</Ink.Text>;
|
|
74
75
|
|
|
75
76
|
if (merged_pr) {
|
|
76
|
-
if (actions.isDebug()) {
|
|
77
|
-
actions.output(
|
|
78
|
-
<FormatText
|
|
79
|
-
wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
|
|
80
|
-
message="Dropping {commit_message} {pr_status}"
|
|
81
|
-
values={{
|
|
82
|
-
commit_message: <Brackets>{commit.subject_line}</Brackets>,
|
|
83
|
-
pr_status: <Parens>MERGED</Parens>,
|
|
84
|
-
}}
|
|
85
|
-
/>,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (actions.isDebug()) {
|
|
93
77
|
actions.output(
|
|
94
78
|
<FormatText
|
|
95
79
|
wrapper={<Ink.Text color={colors.yellow} wrap="truncate-end" />}
|
|
96
|
-
message="
|
|
80
|
+
message="Dropping {pr_status} {commit_message}"
|
|
97
81
|
values={{
|
|
98
|
-
|
|
82
|
+
pr_status: <Ink.Text color={colors.purple}>MERGED</Ink.Text>,
|
|
83
|
+
commit_message,
|
|
99
84
|
}}
|
|
100
85
|
/>,
|
|
101
86
|
);
|
|
87
|
+
|
|
88
|
+
continue;
|
|
102
89
|
}
|
|
103
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
|
+
|
|
104
101
|
picked_commit_list.push(commit);
|
|
105
102
|
}
|
|
106
103
|
|
|
@@ -120,38 +117,38 @@ Rebase.run = async function run() {
|
|
|
120
117
|
|
|
121
118
|
restore_git();
|
|
122
119
|
|
|
123
|
-
const next_commit_range = await CommitMetadata.range();
|
|
124
|
-
|
|
125
|
-
actions.output(
|
|
126
|
-
<FormatText
|
|
127
|
-
wrapper={<Ink.Text color={colors.green} />}
|
|
128
|
-
message="✅ {branch_name} in sync with {origin_branch}"
|
|
129
|
-
values={{
|
|
130
|
-
branch_name: <Brackets>{branch_name}</Brackets>,
|
|
131
|
-
origin_branch: <Brackets>{`origin/${master_branch}`}</Brackets>,
|
|
132
|
-
}}
|
|
133
|
-
/>,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
120
|
actions.unregister_abort_handler();
|
|
137
|
-
|
|
138
|
-
actions.set((state) => {
|
|
139
|
-
state.commit_range = next_commit_range;
|
|
140
|
-
state.step = "status";
|
|
141
|
-
});
|
|
142
121
|
} catch (err) {
|
|
143
122
|
actions.error("Unable to rebase.");
|
|
144
123
|
|
|
145
124
|
if (err instanceof Error) {
|
|
146
|
-
|
|
147
|
-
actions.error(err.message);
|
|
148
|
-
}
|
|
125
|
+
actions.error(err.message);
|
|
149
126
|
}
|
|
150
127
|
|
|
151
|
-
handle_exit();
|
|
152
128
|
actions.exit(20);
|
|
153
129
|
}
|
|
154
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
|
+
|
|
155
152
|
// cleanup git operations if cancelled during manual rebase
|
|
156
153
|
function restore_git() {
|
|
157
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
|
-
|
|
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
|
};
|