git-stack-cli 1.8.3 → 1.9.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/cjs/index.cjs +234 -69
- package/package.json +1 -1
- package/src/app/App.tsx +30 -13
- package/src/app/PreManualRebase.tsx +0 -1
- package/src/app/Store.tsx +2 -0
- package/src/command.ts +133 -93
- package/src/commands/Fixup.tsx +121 -0
- package/src/commands/Log.tsx +72 -0
- package/src/core/CommitMetadata.ts +23 -0
- package/src/core/GitReviseTodo.test.ts +389 -397
- package/src/core/GitReviseTodo.ts +4 -1
- package/src/core/Metadata.test.ts +85 -0
- package/src/core/Metadata.ts +5 -5
- package/src/index.tsx +1 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -26198,6 +26198,7 @@ function LogTimestamp() {
|
|
|
26198
26198
|
|
|
26199
26199
|
const BaseStore = createStore()(immer((set, get) => ({
|
|
26200
26200
|
// set immediately in `index.tsx` so no `null` scenario
|
|
26201
|
+
process_argv: [],
|
|
26201
26202
|
argv: {},
|
|
26202
26203
|
ink: {},
|
|
26203
26204
|
cwd: "",
|
|
@@ -27178,9 +27179,9 @@ function format_time(date) {
|
|
|
27178
27179
|
}
|
|
27179
27180
|
|
|
27180
27181
|
function GithubApiError() {
|
|
27181
|
-
return reactExports.createElement(Await, { fallback: null, function: run$
|
|
27182
|
+
return reactExports.createElement(Await, { fallback: null, function: run$7 });
|
|
27182
27183
|
}
|
|
27183
|
-
async function run$
|
|
27184
|
+
async function run$7() {
|
|
27184
27185
|
const actions = Store.getState().actions;
|
|
27185
27186
|
const res = await cli(`gh api https://api.github.com/rate_limit`);
|
|
27186
27187
|
const res_json = JSON.parse(res.stdout);
|
|
@@ -27228,15 +27229,14 @@ const RE$2 = {
|
|
|
27228
27229
|
|
|
27229
27230
|
function write$1(message, values) {
|
|
27230
27231
|
let result = message;
|
|
27231
|
-
// escape double-quote for cli
|
|
27232
|
-
result = safe_quote(result);
|
|
27233
27232
|
// remove any previous metadata lines
|
|
27234
27233
|
result = remove(result);
|
|
27235
27234
|
const line_list = [result, "", TEMPLATE$1.stack_id(values.id)];
|
|
27236
27235
|
if (values.title) {
|
|
27237
27236
|
line_list.push(TEMPLATE$1.group_title(values.title));
|
|
27238
27237
|
}
|
|
27239
|
-
|
|
27238
|
+
let new_message = line_list.join("\n");
|
|
27239
|
+
new_message = safe_quote(new_message);
|
|
27240
27240
|
return new_message;
|
|
27241
27241
|
}
|
|
27242
27242
|
function read(message) {
|
|
@@ -27269,7 +27269,8 @@ const TEMPLATE$1 = {
|
|
|
27269
27269
|
},
|
|
27270
27270
|
};
|
|
27271
27271
|
const RE$1 = {
|
|
27272
|
-
|
|
27272
|
+
// https://regex101.com/r/wLmGVq/1
|
|
27273
|
+
stack_id: new RegExp(`${TEMPLATE$1.stack_id("(?<id>[^\\s]+)")}`, "i"),
|
|
27273
27274
|
group_title: new RegExp(TEMPLATE$1.group_title("(?<title>[^\\n^\\r]+)"), "i"),
|
|
27274
27275
|
};
|
|
27275
27276
|
|
|
@@ -27515,17 +27516,33 @@ async function range(commit_group_map) {
|
|
|
27515
27516
|
}
|
|
27516
27517
|
async function get_commit_list() {
|
|
27517
27518
|
const master_branch = Store.getState().master_branch;
|
|
27519
|
+
const branch_name = Store.getState().branch_name;
|
|
27520
|
+
invariant(branch_name, "branch_name must exist");
|
|
27518
27521
|
const log_result = await cli(`git log ${master_branch}..HEAD --oneline --format=%H --color=never`);
|
|
27519
27522
|
if (!log_result.stdout) {
|
|
27520
27523
|
return [];
|
|
27521
27524
|
}
|
|
27522
27525
|
const sha_list = lines(log_result.stdout).reverse();
|
|
27523
27526
|
const commit_metadata_list = [];
|
|
27527
|
+
let has_metadata = false;
|
|
27524
27528
|
for (let i = 0; i < sha_list.length; i++) {
|
|
27525
27529
|
const sha = sha_list[i];
|
|
27526
27530
|
const commit_metadata = await commit(sha);
|
|
27531
|
+
if (commit_metadata.branch_id) {
|
|
27532
|
+
has_metadata = true;
|
|
27533
|
+
}
|
|
27527
27534
|
commit_metadata_list.push(commit_metadata);
|
|
27528
27535
|
}
|
|
27536
|
+
if (!has_metadata) {
|
|
27537
|
+
// check for pr with matching branch name to initialize group
|
|
27538
|
+
const pr_result = await pr_status(branch_name);
|
|
27539
|
+
if (pr_result) {
|
|
27540
|
+
for (const commit_metadata of commit_metadata_list) {
|
|
27541
|
+
commit_metadata.branch_id = branch_name;
|
|
27542
|
+
commit_metadata.title = pr_result.title;
|
|
27543
|
+
}
|
|
27544
|
+
}
|
|
27545
|
+
}
|
|
27529
27546
|
return commit_metadata_list;
|
|
27530
27547
|
}
|
|
27531
27548
|
async function commit(sha) {
|
|
@@ -27648,9 +27665,9 @@ function encode(value) {
|
|
|
27648
27665
|
}
|
|
27649
27666
|
|
|
27650
27667
|
function LocalMergeRebase() {
|
|
27651
|
-
return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits\u2026"), function: run$
|
|
27668
|
+
return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits\u2026"), function: run$6 }));
|
|
27652
27669
|
}
|
|
27653
|
-
async function run$
|
|
27670
|
+
async function run$6() {
|
|
27654
27671
|
const state = Store.getState();
|
|
27655
27672
|
const actions = state.actions;
|
|
27656
27673
|
const branch_name = state.branch_name;
|
|
@@ -27819,7 +27836,8 @@ function GitReviseTodo(args) {
|
|
|
27819
27836
|
// update git commit message with stack id
|
|
27820
27837
|
const metadata = { id: group.id, title: group.title };
|
|
27821
27838
|
const unsafe_message_with_id = write$1(commit.full_message, metadata);
|
|
27822
|
-
|
|
27839
|
+
let message_with_id = unsafe_message_with_id;
|
|
27840
|
+
message_with_id = message_with_id.replace(/[^\\]"/g, '\\"');
|
|
27823
27841
|
// get first 12 characters of commit sha
|
|
27824
27842
|
const sha = commit.sha.slice(0, 12);
|
|
27825
27843
|
// generate git revise entry
|
|
@@ -27940,9 +27958,9 @@ const RE = {
|
|
|
27940
27958
|
};
|
|
27941
27959
|
|
|
27942
27960
|
function ManualRebase() {
|
|
27943
|
-
return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits\u2026"), function: run$
|
|
27961
|
+
return (reactExports.createElement(Await, { fallback: reactExports.createElement(Text, { color: colors.yellow }, "Rebasing commits\u2026"), function: run$5 }));
|
|
27944
27962
|
}
|
|
27945
|
-
async function run$
|
|
27963
|
+
async function run$5() {
|
|
27946
27964
|
const state = Store.getState();
|
|
27947
27965
|
const actions = state.actions;
|
|
27948
27966
|
const argv = state.argv;
|
|
@@ -28453,9 +28471,9 @@ function get_status_bold(row) {
|
|
|
28453
28471
|
}
|
|
28454
28472
|
|
|
28455
28473
|
function PostRebaseStatus() {
|
|
28456
|
-
return reactExports.createElement(Await, { fallback: null, function: run$
|
|
28474
|
+
return reactExports.createElement(Await, { fallback: null, function: run$4 });
|
|
28457
28475
|
}
|
|
28458
|
-
async function run$
|
|
28476
|
+
async function run$4() {
|
|
28459
28477
|
const actions = Store.getState().actions;
|
|
28460
28478
|
// reset github pr cache before refreshing via commit range below
|
|
28461
28479
|
actions.reset_pr();
|
|
@@ -28485,15 +28503,14 @@ function PreLocalMergeRebase() {
|
|
|
28485
28503
|
}
|
|
28486
28504
|
|
|
28487
28505
|
function PreManualRebase() {
|
|
28488
|
-
return reactExports.createElement(Await, { fallback: null, function: run$
|
|
28506
|
+
return reactExports.createElement(Await, { fallback: null, function: run$3 });
|
|
28489
28507
|
}
|
|
28490
|
-
async function run$
|
|
28508
|
+
async function run$3() {
|
|
28491
28509
|
const state = Store.getState();
|
|
28492
28510
|
const actions = state.actions;
|
|
28493
28511
|
const repo_root = state.repo_root;
|
|
28494
28512
|
const argv = state.argv;
|
|
28495
28513
|
invariant(repo_root, "repo_root must exist");
|
|
28496
|
-
invariant(argv, "argv must exist");
|
|
28497
28514
|
if (!argv.template) {
|
|
28498
28515
|
return actions.set((state) => {
|
|
28499
28516
|
state.step = "manual-rebase";
|
|
@@ -28993,9 +29010,9 @@ const SYMBOL = {
|
|
|
28993
29010
|
};
|
|
28994
29011
|
|
|
28995
29012
|
function Status() {
|
|
28996
|
-
return reactExports.createElement(Await, { fallback: null, function: run });
|
|
29013
|
+
return reactExports.createElement(Await, { fallback: null, function: run$2 });
|
|
28997
29014
|
}
|
|
28998
|
-
async function run() {
|
|
29015
|
+
async function run$2() {
|
|
28999
29016
|
const state = Store.getState();
|
|
29000
29017
|
const actions = state.actions;
|
|
29001
29018
|
const argv = state.argv;
|
|
@@ -29138,6 +29155,123 @@ function RebaseCheck(props) {
|
|
|
29138
29155
|
}
|
|
29139
29156
|
}
|
|
29140
29157
|
|
|
29158
|
+
function Fixup() {
|
|
29159
|
+
return reactExports.createElement(Await, { fallback: null, function: run$1 });
|
|
29160
|
+
}
|
|
29161
|
+
async function run$1() {
|
|
29162
|
+
const state = Store.getState();
|
|
29163
|
+
const actions = state.actions;
|
|
29164
|
+
const argv = state.argv;
|
|
29165
|
+
const relative_number = argv.commit;
|
|
29166
|
+
if (!relative_number) {
|
|
29167
|
+
actions.output(reactExports.createElement(Text, { color: colors.red },
|
|
29168
|
+
"\u2757\uFE0F Usage: git fixup ",
|
|
29169
|
+
"<relative-commit-number>"));
|
|
29170
|
+
actions.output("");
|
|
29171
|
+
actions.output("This script automates the process of adding staged changes as a fixup commit");
|
|
29172
|
+
actions.output("and the subsequent git rebase to flatten the commits based on relative commit number");
|
|
29173
|
+
actions.output("You can use a `git log` like below to get the relative commit number");
|
|
29174
|
+
actions.output("");
|
|
29175
|
+
actions.output(" ❯ git stack log");
|
|
29176
|
+
actions.output(" 1\te329794d5f881cbf0fc3f26d2108cf6f3fdebabe enable drop_error_subtask test param");
|
|
29177
|
+
actions.output(" 2\t57f43b596e5c6b97bc47e2a591f82ccc81651156 test drop_error_subtask baseline");
|
|
29178
|
+
actions.output(" 3\t838e878d483c6a2d5393063fc59baf2407225c6d ErrorSubtask test baseline");
|
|
29179
|
+
actions.output("");
|
|
29180
|
+
actions.output("To target `838e87` above, you would call `fixup 3`");
|
|
29181
|
+
actions.exit(0);
|
|
29182
|
+
}
|
|
29183
|
+
const diff_staged_cmd = await cli("git diff --cached --quiet", {
|
|
29184
|
+
ignoreExitCode: true,
|
|
29185
|
+
});
|
|
29186
|
+
if (!diff_staged_cmd.code) {
|
|
29187
|
+
actions.error("🚨 Stage changes before calling fixup");
|
|
29188
|
+
actions.exit(1);
|
|
29189
|
+
// actions.output(
|
|
29190
|
+
// <Ink.Text color={colors.red}>
|
|
29191
|
+
// ❗️ Usage: git fixup {"<relative-commit-number>"}
|
|
29192
|
+
// </Ink.Text>
|
|
29193
|
+
// );
|
|
29194
|
+
}
|
|
29195
|
+
// Calculate commit SHA based on the relative commit number
|
|
29196
|
+
const adjusted_number = Number(relative_number) - 1;
|
|
29197
|
+
// get the commit SHA of the target commit
|
|
29198
|
+
const commit_sha = (await cli(`git rev-parse HEAD~${adjusted_number}`))
|
|
29199
|
+
.stdout;
|
|
29200
|
+
await cli(`git commit --fixup ${commit_sha}`);
|
|
29201
|
+
// check if stash required
|
|
29202
|
+
let save_stash = false;
|
|
29203
|
+
const diff_cmd = await cli("git diff-index --quiet HEAD --", {
|
|
29204
|
+
ignoreExitCode: true,
|
|
29205
|
+
});
|
|
29206
|
+
if (diff_cmd.code) {
|
|
29207
|
+
save_stash = true;
|
|
29208
|
+
await cli("git stash -q");
|
|
29209
|
+
actions.output(reactExports.createElement(Text, null, "\uD83D\uDCE6 Changes saved to stash"));
|
|
29210
|
+
}
|
|
29211
|
+
// rebase target needs to account for new commit created above
|
|
29212
|
+
const rebase_target = Number(relative_number) + 1;
|
|
29213
|
+
await cli(`git rebase -i --autosquash HEAD~${rebase_target}`, {
|
|
29214
|
+
env: {
|
|
29215
|
+
PATH: process.env.PATH,
|
|
29216
|
+
GIT_EDITOR: "true",
|
|
29217
|
+
},
|
|
29218
|
+
});
|
|
29219
|
+
actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow }), message: "\uD83D\uDEE0\uFE0F fixup {relative_number} {commit_sha}", values: {
|
|
29220
|
+
commit_sha: reactExports.createElement(Parens, null, commit_sha),
|
|
29221
|
+
relative_number: relative_number,
|
|
29222
|
+
} }));
|
|
29223
|
+
if (save_stash) {
|
|
29224
|
+
await cli("git stash pop -q");
|
|
29225
|
+
actions.output(reactExports.createElement(Text, { color: colors.green }, "\u2705 Changes restored from stash"));
|
|
29226
|
+
}
|
|
29227
|
+
}
|
|
29228
|
+
|
|
29229
|
+
function Log() {
|
|
29230
|
+
const { stdout } = useStdout();
|
|
29231
|
+
const available_width = stdout.columns || 80;
|
|
29232
|
+
return reactExports.createElement(Await, { fallback: null, function: () => run({ available_width }) });
|
|
29233
|
+
}
|
|
29234
|
+
async function run(args) {
|
|
29235
|
+
const state = Store.getState();
|
|
29236
|
+
const actions = state.actions;
|
|
29237
|
+
const process_argv = state.process_argv;
|
|
29238
|
+
invariant(actions, "actions must exist");
|
|
29239
|
+
// estimate the number of color characters per line
|
|
29240
|
+
// assuming an average of 5 color changes per line and 5 characters per color code
|
|
29241
|
+
const color_buffer = 12 * 5;
|
|
29242
|
+
const truncation_width = args.available_width + color_buffer;
|
|
29243
|
+
// get the number of characters in the short sha for this repo
|
|
29244
|
+
const short_sha = (await cli(`git log -1 --format=%h`)).stdout.trim();
|
|
29245
|
+
const short_sha_length = short_sha.length + 1;
|
|
29246
|
+
// SHA hash - At least 9 characters wide, truncated
|
|
29247
|
+
const sha_format = `%C(green)%<(${short_sha_length},trunc)%h`;
|
|
29248
|
+
// relative commit date - 15 characters wide, truncated
|
|
29249
|
+
const date_format = `%C(white)%<(15,trunc)%cr`;
|
|
29250
|
+
// author's abbreviated name - 12 characters wide, truncated
|
|
29251
|
+
const author_format = `%C(white)%<(8,trunc)%al`;
|
|
29252
|
+
// decorative information like branch heads or tags
|
|
29253
|
+
const decoration_format = `%C(auto)%d`;
|
|
29254
|
+
// commit subject - 80 characters wide, truncated
|
|
29255
|
+
const subject_format = `%<(60,trunc)%s`;
|
|
29256
|
+
// combine all the above formats into one
|
|
29257
|
+
const format = [
|
|
29258
|
+
sha_format,
|
|
29259
|
+
date_format,
|
|
29260
|
+
author_format,
|
|
29261
|
+
decoration_format,
|
|
29262
|
+
subject_format,
|
|
29263
|
+
].join(" ");
|
|
29264
|
+
// view the SHA, description and history graph of last 20 commits
|
|
29265
|
+
const rest_args = process_argv.slice(3).join(" ");
|
|
29266
|
+
const command = [
|
|
29267
|
+
`git log --pretty=format:"${format}" -n20 --graph --color ${rest_args}`,
|
|
29268
|
+
`cut -c 1-"${truncation_width}"`,
|
|
29269
|
+
`nl -w3 -s' '`,
|
|
29270
|
+
].join(" | ");
|
|
29271
|
+
const result = await cli(command);
|
|
29272
|
+
actions.output(result.stdout);
|
|
29273
|
+
}
|
|
29274
|
+
|
|
29141
29275
|
function App() {
|
|
29142
29276
|
const actions = Store.useActions();
|
|
29143
29277
|
const ink = Store.useState((state) => state.ink);
|
|
@@ -29162,13 +29296,24 @@ function App() {
|
|
|
29162
29296
|
}
|
|
29163
29297
|
} },
|
|
29164
29298
|
reactExports.createElement(DependencyCheck, null,
|
|
29165
|
-
reactExports.createElement(
|
|
29166
|
-
reactExports.createElement(
|
|
29167
|
-
reactExports.createElement(
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29299
|
+
reactExports.createElement(RebaseCheck, null,
|
|
29300
|
+
reactExports.createElement(CherryPickCheck, null,
|
|
29301
|
+
reactExports.createElement(MaybeMain, null)))))));
|
|
29302
|
+
}
|
|
29303
|
+
function MaybeMain() {
|
|
29304
|
+
const argv = Store.useState((state) => state.argv);
|
|
29305
|
+
const positional_list = new Set(argv["_"]);
|
|
29306
|
+
if (positional_list.has("fixup")) {
|
|
29307
|
+
return reactExports.createElement(Fixup, null);
|
|
29308
|
+
}
|
|
29309
|
+
else if (positional_list.has("log")) {
|
|
29310
|
+
return reactExports.createElement(Log, null);
|
|
29311
|
+
}
|
|
29312
|
+
return (reactExports.createElement(DirtyCheck, null,
|
|
29313
|
+
!argv.verbose ? null : reactExports.createElement(GithubApiError, null),
|
|
29314
|
+
reactExports.createElement(GatherMetadata, null,
|
|
29315
|
+
reactExports.createElement(LocalCommitStatus, null,
|
|
29316
|
+
reactExports.createElement(Main, null)))));
|
|
29172
29317
|
}
|
|
29173
29318
|
|
|
29174
29319
|
const align = {
|
|
@@ -34476,32 +34621,60 @@ const Yargs = YargsFactory(shim$1);
|
|
|
34476
34621
|
|
|
34477
34622
|
async function command() {
|
|
34478
34623
|
// https://yargs.js.org/docs/#api-reference-optionkey-opt
|
|
34479
|
-
return
|
|
34480
|
-
.usage("Usage: git stack [options]")
|
|
34481
|
-
.
|
|
34624
|
+
return Yargs(hideBin(process.argv))
|
|
34625
|
+
.usage("Usage: git stack [command] [options]")
|
|
34626
|
+
.command("$0", "Sync commit ranges to Github", (yargs) => yargs.options(DefaultOptions))
|
|
34627
|
+
.command("fixup [commit]", "Amend staged changes to a specific commit in history", (yargs) => yargs.positional("commit", FixupOptions.commit))
|
|
34628
|
+
.command("log [args...]", "Print an abbreviated log with numbered commits, useful for git stack fixup", (yargs) => yargs.strict(false))
|
|
34629
|
+
.option("verbose", GlobalOptions.verbose)
|
|
34630
|
+
// yargs default wraps to 80 columns
|
|
34631
|
+
// passing null will wrap to terminal width
|
|
34632
|
+
// value below if what seems to look decent
|
|
34633
|
+
.wrap(123)
|
|
34634
|
+
// disallow unknown options
|
|
34635
|
+
.strict()
|
|
34636
|
+
.version("1.9.0" )
|
|
34637
|
+
.showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
|
|
34638
|
+
.help("help", "Show usage via `git stack help`")
|
|
34639
|
+
.argv;
|
|
34640
|
+
}
|
|
34641
|
+
const Rebase = Object.freeze({
|
|
34642
|
+
"git-revise": "git-revise",
|
|
34643
|
+
"cherry-pick": "cherry-pick",
|
|
34644
|
+
});
|
|
34645
|
+
const GlobalOptions = {
|
|
34646
|
+
verbose: {
|
|
34647
|
+
type: "boolean",
|
|
34648
|
+
alias: ["v"],
|
|
34649
|
+
default: false,
|
|
34650
|
+
description: "Print more detailed logs for debugging internals",
|
|
34651
|
+
},
|
|
34652
|
+
};
|
|
34653
|
+
const DefaultOptions = {
|
|
34654
|
+
"force": {
|
|
34482
34655
|
type: "boolean",
|
|
34483
34656
|
alias: ["f"],
|
|
34484
34657
|
default: false,
|
|
34485
34658
|
description: "Force sync even if no changes are detected",
|
|
34486
|
-
}
|
|
34487
|
-
|
|
34659
|
+
},
|
|
34660
|
+
"check": {
|
|
34488
34661
|
type: "boolean",
|
|
34489
34662
|
alias: ["c"],
|
|
34490
34663
|
default: false,
|
|
34491
34664
|
description: "Print status table and exit without syncing",
|
|
34492
|
-
}
|
|
34493
|
-
|
|
34665
|
+
},
|
|
34666
|
+
"sync": {
|
|
34494
34667
|
type: "boolean",
|
|
34495
34668
|
alias: ["s"],
|
|
34496
34669
|
default: true,
|
|
34497
34670
|
description: "Sync commit ranges to Github, disable with --no-sync",
|
|
34498
|
-
}
|
|
34499
|
-
|
|
34671
|
+
},
|
|
34672
|
+
"verify": {
|
|
34500
34673
|
type: "boolean",
|
|
34501
34674
|
default: true,
|
|
34502
34675
|
description: "Run git hooks such as pre-commit and pre-push, disable with --no-verify",
|
|
34503
|
-
}
|
|
34504
|
-
|
|
34676
|
+
},
|
|
34677
|
+
"rebase": {
|
|
34505
34678
|
type: "string",
|
|
34506
34679
|
choices: [Rebase["git-revise"], Rebase["cherry-pick"]],
|
|
34507
34680
|
default: Rebase["git-revise"],
|
|
@@ -34510,67 +34683,59 @@ async function command() {
|
|
|
34510
34683
|
`${Rebase["git-revise"]}: perform faster in-memory rebase`,
|
|
34511
34684
|
`${Rebase["cherry-pick"]}: use disk and incrementally rebase each commit`,
|
|
34512
34685
|
].join(" | "),
|
|
34513
|
-
}
|
|
34514
|
-
|
|
34515
|
-
type: "boolean",
|
|
34516
|
-
alias: ["v"],
|
|
34517
|
-
default: false,
|
|
34518
|
-
description: "Print more detailed logs for debugging internals",
|
|
34519
|
-
})
|
|
34520
|
-
.option("update", {
|
|
34686
|
+
},
|
|
34687
|
+
"update": {
|
|
34521
34688
|
type: "boolean",
|
|
34522
34689
|
alias: ["u", "upgrade"],
|
|
34523
34690
|
default: false,
|
|
34524
34691
|
description: "Check and install the latest version",
|
|
34525
|
-
}
|
|
34526
|
-
|
|
34692
|
+
},
|
|
34693
|
+
"branch": {
|
|
34527
34694
|
type: "string",
|
|
34528
34695
|
alias: ["b"],
|
|
34529
34696
|
description: 'Set the master branch name, defaults to "master" (or "main" if "master" is not found)',
|
|
34530
|
-
}
|
|
34531
|
-
|
|
34697
|
+
},
|
|
34698
|
+
"draft": {
|
|
34532
34699
|
type: "boolean",
|
|
34533
34700
|
alias: ["d"],
|
|
34534
34701
|
default: false,
|
|
34535
34702
|
description: "Open all PRs as drafts",
|
|
34536
|
-
}
|
|
34537
|
-
|
|
34703
|
+
},
|
|
34704
|
+
"write-state-json": {
|
|
34538
34705
|
hidden: true,
|
|
34539
34706
|
type: "boolean",
|
|
34540
34707
|
default: false,
|
|
34541
34708
|
description: "Write state to local json file for debugging",
|
|
34542
|
-
}
|
|
34543
|
-
|
|
34709
|
+
},
|
|
34710
|
+
"template": {
|
|
34544
34711
|
type: "boolean",
|
|
34545
34712
|
default: true,
|
|
34546
34713
|
description: "Use automatic Github PR template, e.g. .github/pull_request_template.md, disable with --no-template",
|
|
34547
|
-
}
|
|
34548
|
-
|
|
34714
|
+
},
|
|
34715
|
+
"mock-metadata": {
|
|
34549
34716
|
hidden: true,
|
|
34550
34717
|
type: "boolean",
|
|
34551
34718
|
default: false,
|
|
34552
34719
|
description: "Mock local store metadata for testing",
|
|
34553
|
-
}
|
|
34554
|
-
|
|
34555
|
-
|
|
34556
|
-
|
|
34557
|
-
|
|
34558
|
-
|
|
34559
|
-
|
|
34560
|
-
|
|
34561
|
-
|
|
34562
|
-
.
|
|
34563
|
-
}
|
|
34564
|
-
|
|
34565
|
-
"git-revise": "git-revise",
|
|
34566
|
-
"cherry-pick": "cherry-pick",
|
|
34567
|
-
});
|
|
34720
|
+
},
|
|
34721
|
+
};
|
|
34722
|
+
const FixupOptions = {
|
|
34723
|
+
commit: {
|
|
34724
|
+
type: "number",
|
|
34725
|
+
default: 1,
|
|
34726
|
+
description: [
|
|
34727
|
+
"Relative number of commit to amend staged changes.",
|
|
34728
|
+
"Most recent is 1, next is 2, etc.",
|
|
34729
|
+
].join("\n"),
|
|
34730
|
+
},
|
|
34731
|
+
};
|
|
34568
34732
|
|
|
34569
34733
|
command()
|
|
34570
34734
|
.then((argv) => {
|
|
34571
34735
|
const ink = render(reactExports.createElement(App, null));
|
|
34572
34736
|
Store.setState((state) => {
|
|
34573
34737
|
state.ink = ink;
|
|
34738
|
+
state.process_argv = process.argv;
|
|
34574
34739
|
state.argv = argv;
|
|
34575
34740
|
state.cwd = process.cwd();
|
|
34576
34741
|
});
|
package/package.json
CHANGED
package/src/app/App.tsx
CHANGED
|
@@ -13,6 +13,8 @@ import { Output } from "~/app/Output";
|
|
|
13
13
|
import { Providers } from "~/app/Providers";
|
|
14
14
|
import { RebaseCheck } from "~/app/RebaseCheck";
|
|
15
15
|
import { Store } from "~/app/Store";
|
|
16
|
+
import { Fixup } from "~/commands/Fixup";
|
|
17
|
+
import { Log } from "~/commands/Log";
|
|
16
18
|
|
|
17
19
|
export function App() {
|
|
18
20
|
const actions = Store.useActions();
|
|
@@ -51,21 +53,36 @@ export function App() {
|
|
|
51
53
|
}}
|
|
52
54
|
>
|
|
53
55
|
<DependencyCheck>
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<GatherMetadata>
|
|
60
|
-
<LocalCommitStatus>
|
|
61
|
-
<Main />
|
|
62
|
-
</LocalCommitStatus>
|
|
63
|
-
</GatherMetadata>
|
|
64
|
-
</CherryPickCheck>
|
|
65
|
-
</RebaseCheck>
|
|
66
|
-
</DirtyCheck>
|
|
56
|
+
<RebaseCheck>
|
|
57
|
+
<CherryPickCheck>
|
|
58
|
+
<MaybeMain />
|
|
59
|
+
</CherryPickCheck>
|
|
60
|
+
</RebaseCheck>
|
|
67
61
|
</DependencyCheck>
|
|
68
62
|
</AutoUpdate>
|
|
69
63
|
</Providers>
|
|
70
64
|
);
|
|
71
65
|
}
|
|
66
|
+
function MaybeMain() {
|
|
67
|
+
const argv = Store.useState((state) => state.argv);
|
|
68
|
+
|
|
69
|
+
const positional_list = new Set(argv["_"]);
|
|
70
|
+
|
|
71
|
+
if (positional_list.has("fixup")) {
|
|
72
|
+
return <Fixup />;
|
|
73
|
+
} else if (positional_list.has("log")) {
|
|
74
|
+
return <Log />;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<DirtyCheck>
|
|
79
|
+
{!argv.verbose ? null : <GithubApiError />}
|
|
80
|
+
|
|
81
|
+
<GatherMetadata>
|
|
82
|
+
<LocalCommitStatus>
|
|
83
|
+
<Main />
|
|
84
|
+
</LocalCommitStatus>
|
|
85
|
+
</GatherMetadata>
|
|
86
|
+
</DirtyCheck>
|
|
87
|
+
);
|
|
88
|
+
}
|
package/src/app/Store.tsx
CHANGED
|
@@ -26,6 +26,7 @@ type MutateOutputArgs = {
|
|
|
26
26
|
|
|
27
27
|
export type State = {
|
|
28
28
|
// set immediately in `index.tsx` so no `null` scenario
|
|
29
|
+
process_argv: Array<string>;
|
|
29
30
|
argv: Argv;
|
|
30
31
|
ink: InkInstance;
|
|
31
32
|
cwd: string;
|
|
@@ -89,6 +90,7 @@ export type State = {
|
|
|
89
90
|
const BaseStore = createStore<State>()(
|
|
90
91
|
immer((set, get) => ({
|
|
91
92
|
// set immediately in `index.tsx` so no `null` scenario
|
|
93
|
+
process_argv: [],
|
|
92
94
|
argv: {} as Argv,
|
|
93
95
|
ink: {} as InkInstance,
|
|
94
96
|
cwd: "",
|