git-stack-cli 2.4.1 → 2.5.1
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 +64 -77
- package/package.json +1 -1
- package/src/app/App.tsx +16 -16
- package/src/app/DependencyCheck.tsx +18 -3
- package/src/app/SyncGithub.tsx +1 -60
- package/src/command.ts +21 -5
- package/src/core/GitReviseTodo.ts +27 -5
package/dist/js/index.js
CHANGED
|
@@ -37869,7 +37869,13 @@ var RE = {
|
|
|
37869
37869
|
|
|
37870
37870
|
// src/app/DependencyCheck.tsx
|
|
37871
37871
|
function DependencyCheck(props) {
|
|
37872
|
-
return /* @__PURE__ */ React23.createElement(CheckGit, null, /* @__PURE__ */ React23.createElement(CheckGithubCli,
|
|
37872
|
+
return /* @__PURE__ */ React23.createElement(CheckGit, null, /* @__PURE__ */ React23.createElement(CheckGithubCli, {
|
|
37873
|
+
...props
|
|
37874
|
+
}, /* @__PURE__ */ React23.createElement(CheckGithubCliAuth, {
|
|
37875
|
+
...props
|
|
37876
|
+
}, /* @__PURE__ */ React23.createElement(CheckGitRevise, {
|
|
37877
|
+
...props
|
|
37878
|
+
}, props.children))));
|
|
37873
37879
|
}
|
|
37874
37880
|
function CheckGit(props) {
|
|
37875
37881
|
const actions = Store.useActions();
|
|
@@ -37890,6 +37896,9 @@ function CheckGit(props) {
|
|
|
37890
37896
|
}
|
|
37891
37897
|
function CheckGithubCli(props) {
|
|
37892
37898
|
const actions = Store.useActions();
|
|
37899
|
+
if (props.disableGithubCli) {
|
|
37900
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, props.children);
|
|
37901
|
+
}
|
|
37893
37902
|
return /* @__PURE__ */ React23.createElement(Await, {
|
|
37894
37903
|
fallback: /* @__PURE__ */ React23.createElement(Text, {
|
|
37895
37904
|
color: colors.yellow
|
|
@@ -37917,6 +37926,9 @@ function CheckGithubCli(props) {
|
|
|
37917
37926
|
}
|
|
37918
37927
|
function CheckGithubCliAuth(props) {
|
|
37919
37928
|
const actions = Store.useActions();
|
|
37929
|
+
if (props.disableGithubCliAuth) {
|
|
37930
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, props.children);
|
|
37931
|
+
}
|
|
37920
37932
|
return /* @__PURE__ */ React23.createElement(Await, {
|
|
37921
37933
|
fallback: /* @__PURE__ */ React23.createElement(Text, {
|
|
37922
37934
|
color: colors.yellow
|
|
@@ -37952,6 +37964,9 @@ function CheckGithubCliAuth(props) {
|
|
|
37952
37964
|
}
|
|
37953
37965
|
function CheckGitRevise(props) {
|
|
37954
37966
|
const actions = Store.useActions();
|
|
37967
|
+
if (props.disableGitRevise) {
|
|
37968
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, props.children);
|
|
37969
|
+
}
|
|
37955
37970
|
return /* @__PURE__ */ React23.createElement(Await, {
|
|
37956
37971
|
fallback: /* @__PURE__ */ React23.createElement(Text, {
|
|
37957
37972
|
color: colors.yellow
|
|
@@ -38161,32 +38176,6 @@ async function pr_edit(args) {
|
|
|
38161
38176
|
await safe_rm(body_file);
|
|
38162
38177
|
}
|
|
38163
38178
|
}
|
|
38164
|
-
async function pr_draft(args) {
|
|
38165
|
-
const mutation_name = args.draft ? "convertPullRequestToDraft" : "markPullRequestReadyForReview";
|
|
38166
|
-
let query = `
|
|
38167
|
-
mutation($id: ID!) {
|
|
38168
|
-
${mutation_name}(input: { pullRequestId: $id }) {
|
|
38169
|
-
pullRequest {
|
|
38170
|
-
id
|
|
38171
|
-
number
|
|
38172
|
-
isDraft
|
|
38173
|
-
}
|
|
38174
|
-
}
|
|
38175
|
-
}
|
|
38176
|
-
`;
|
|
38177
|
-
query = query.replace(/\n/g, " ");
|
|
38178
|
-
query = query.replace(/\s+/g, " ");
|
|
38179
|
-
query = query.trim();
|
|
38180
|
-
const state = Store.getState();
|
|
38181
|
-
const cache_pr = state.pr[args.branch];
|
|
38182
|
-
invariant(cache_pr, "cache_pr must exist");
|
|
38183
|
-
const command_parts = [`gh api graphql -F id="${cache_pr.id}" -f query='${query}'`];
|
|
38184
|
-
const command = command_parts.join(" ");
|
|
38185
|
-
const cli_result = await cli(command);
|
|
38186
|
-
if (cli_result.code !== 0) {
|
|
38187
|
-
handle_error(cli_result.output);
|
|
38188
|
-
}
|
|
38189
|
-
}
|
|
38190
38179
|
var JSON_FIELDS = "--json id,number,state,baseRefName,headRefName,commits,title,body,url,isDraft";
|
|
38191
38180
|
async function gh_json(command) {
|
|
38192
38181
|
let hash = crypto.createHash("md5").update(command).digest("hex");
|
|
@@ -38415,6 +38404,8 @@ GitReviseTodo.todo = function todo(args) {
|
|
|
38415
38404
|
return todo2;
|
|
38416
38405
|
};
|
|
38417
38406
|
GitReviseTodo.execute = async function grt_execute(args) {
|
|
38407
|
+
const argv = Store.getState().argv;
|
|
38408
|
+
const actions = Store.getState().actions;
|
|
38418
38409
|
const GIT_SEQUENCE_EDITOR_SCRIPT = `#!/bin/sh
|
|
38419
38410
|
|
|
38420
38411
|
# Example
|
|
@@ -38472,10 +38463,30 @@ echo
|
|
|
38472
38463
|
const command = [
|
|
38473
38464
|
`GIT_EDITOR="${tmp_git_sequence_editor_path}"`,
|
|
38474
38465
|
`GIT_REVISE_TODO="${tmp_path_git_revise_todo}"`,
|
|
38475
|
-
`git
|
|
38476
|
-
`revise --edit -i ${args.rebase_merge_base}`
|
|
38466
|
+
`git`
|
|
38477
38467
|
];
|
|
38478
|
-
|
|
38468
|
+
if (!argv["revise-sign"]) {
|
|
38469
|
+
command.push(...["-c", "commit.gpgsign=false"]);
|
|
38470
|
+
}
|
|
38471
|
+
command.push(`revise --edit -i ${args.rebase_merge_base}`);
|
|
38472
|
+
try {
|
|
38473
|
+
await cli(command, { stdio: ["pipe", "pipe", "pipe"] });
|
|
38474
|
+
} catch (err) {
|
|
38475
|
+
if (err instanceof Error) {
|
|
38476
|
+
actions.error(err.message);
|
|
38477
|
+
if (err.message.includes("gpg failed to sign commit")) {
|
|
38478
|
+
actions.error(`
|
|
38479
|
+
|
|
38480
|
+
`);
|
|
38481
|
+
actions.error("\uD83D\uDEA8 git revise failed to sign commit");
|
|
38482
|
+
actions.error("\uD83D\uDCA1 Try again with `--no-revise-sign`?");
|
|
38483
|
+
actions.error(`
|
|
38484
|
+
|
|
38485
|
+
`);
|
|
38486
|
+
actions.exit(21);
|
|
38487
|
+
}
|
|
38488
|
+
}
|
|
38489
|
+
}
|
|
38479
38490
|
await safe_rm(tmp_git_sequence_editor_path);
|
|
38480
38491
|
};
|
|
38481
38492
|
|
|
@@ -40250,13 +40261,6 @@ async function run9() {
|
|
|
40250
40261
|
invariant(sync_github, "sync_github must exist");
|
|
40251
40262
|
const commit_range = sync_github.commit_range;
|
|
40252
40263
|
const rebase_group_index = sync_github.rebase_group_index;
|
|
40253
|
-
actions.register_abort_handler(async function abort_sync_github() {
|
|
40254
|
-
actions.output(/* @__PURE__ */ React44.createElement(Text, {
|
|
40255
|
-
color: colors.red
|
|
40256
|
-
}, "\uD83D\uDEA8 Abort"));
|
|
40257
|
-
handle_exit2();
|
|
40258
|
-
return 17;
|
|
40259
|
-
});
|
|
40260
40264
|
let DEFAULT_PR_BODY = "";
|
|
40261
40265
|
if (state.pr_template_body) {
|
|
40262
40266
|
DEFAULT_PR_BODY = state.pr_template_body;
|
|
@@ -40322,17 +40326,7 @@ async function run9() {
|
|
|
40322
40326
|
async function before_push(args) {
|
|
40323
40327
|
const { group } = args;
|
|
40324
40328
|
invariant(group.base, "group.base must exist");
|
|
40325
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
40326
40329
|
if (group.pr) {
|
|
40327
|
-
if (!group.pr.isDraft) {
|
|
40328
|
-
is_temp_draft = true;
|
|
40329
|
-
}
|
|
40330
|
-
if (is_temp_draft) {
|
|
40331
|
-
await pr_draft({
|
|
40332
|
-
branch: group.id,
|
|
40333
|
-
draft: true
|
|
40334
|
-
});
|
|
40335
|
-
}
|
|
40336
40330
|
await pr_edit({
|
|
40337
40331
|
branch: group.id,
|
|
40338
40332
|
base: master_branch
|
|
@@ -40353,13 +40347,6 @@ async function run9() {
|
|
|
40353
40347
|
selected_url
|
|
40354
40348
|
})
|
|
40355
40349
|
});
|
|
40356
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
40357
|
-
if (is_temp_draft) {
|
|
40358
|
-
await pr_draft({
|
|
40359
|
-
branch: group.id,
|
|
40360
|
-
draft: false
|
|
40361
|
-
});
|
|
40362
|
-
}
|
|
40363
40350
|
} else {
|
|
40364
40351
|
const pr_url = await pr_create({
|
|
40365
40352
|
branch: group.id,
|
|
@@ -40399,23 +40386,6 @@ async function run9() {
|
|
|
40399
40386
|
});
|
|
40400
40387
|
}
|
|
40401
40388
|
}
|
|
40402
|
-
function handle_exit2() {
|
|
40403
|
-
actions.output(/* @__PURE__ */ React44.createElement(Text, {
|
|
40404
|
-
color: colors.yellow
|
|
40405
|
-
}, "Restoring PR state…"));
|
|
40406
|
-
for (const group of push_group_list) {
|
|
40407
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
40408
|
-
if (is_temp_draft) {
|
|
40409
|
-
pr_draft({
|
|
40410
|
-
branch: group.id,
|
|
40411
|
-
draft: false
|
|
40412
|
-
}).catch(actions.error);
|
|
40413
|
-
}
|
|
40414
|
-
}
|
|
40415
|
-
actions.output(/* @__PURE__ */ React44.createElement(Text, {
|
|
40416
|
-
color: colors.yellow
|
|
40417
|
-
}, "Restored PR state."));
|
|
40418
|
-
}
|
|
40419
40389
|
}
|
|
40420
40390
|
var get_group_url = (group) => group.pr?.url || group.id;
|
|
40421
40391
|
|
|
@@ -40785,7 +40755,7 @@ function App2() {
|
|
|
40785
40755
|
actions.exit(0);
|
|
40786
40756
|
}
|
|
40787
40757
|
}
|
|
40788
|
-
}, /* @__PURE__ */ React54.createElement(VerboseDebugInfo, null, /* @__PURE__ */ React54.createElement(
|
|
40758
|
+
}, /* @__PURE__ */ React54.createElement(VerboseDebugInfo, null, /* @__PURE__ */ React54.createElement(RebaseCheck, null, /* @__PURE__ */ React54.createElement(CherryPickCheck, null, /* @__PURE__ */ React54.createElement(MaybeMain, null))))), /* @__PURE__ */ React54.createElement(HandleCtrlCSigint, null))));
|
|
40789
40759
|
}
|
|
40790
40760
|
function MaybeMain() {
|
|
40791
40761
|
const argv = Store.useState((state) => state.argv);
|
|
@@ -40797,7 +40767,7 @@ function MaybeMain() {
|
|
|
40797
40767
|
} else if (positional_list.has("rebase")) {
|
|
40798
40768
|
return /* @__PURE__ */ React54.createElement(GatherMetadata, null, /* @__PURE__ */ React54.createElement(LocalCommitStatus, null, /* @__PURE__ */ React54.createElement(Rebase, null)));
|
|
40799
40769
|
}
|
|
40800
|
-
return /* @__PURE__ */ React54.createElement(React54.Fragment, null, !argv.verbose ? null : /* @__PURE__ */ React54.createElement(GithubApiError, null), /* @__PURE__ */ React54.createElement(GatherMetadata, null, /* @__PURE__ */ React54.createElement(DirtyCheck, null, /* @__PURE__ */ React54.createElement(LocalCommitStatus, null, /* @__PURE__ */ React54.createElement(DetectInitialPR, null, /* @__PURE__ */ React54.createElement(Main, null))))));
|
|
40770
|
+
return /* @__PURE__ */ React54.createElement(React54.Fragment, null, !argv.verbose ? null : /* @__PURE__ */ React54.createElement(GithubApiError, null), /* @__PURE__ */ React54.createElement(DependencyCheck, null, /* @__PURE__ */ React54.createElement(GatherMetadata, null, /* @__PURE__ */ React54.createElement(DirtyCheck, null, /* @__PURE__ */ React54.createElement(LocalCommitStatus, null, /* @__PURE__ */ React54.createElement(DetectInitialPR, null, /* @__PURE__ */ React54.createElement(Main, null)))))));
|
|
40801
40771
|
}
|
|
40802
40772
|
|
|
40803
40773
|
// node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/lib/platform-shims/esm.mjs
|
|
@@ -45662,7 +45632,7 @@ var yargs_default = Yargs;
|
|
|
45662
45632
|
|
|
45663
45633
|
// src/command.ts
|
|
45664
45634
|
async function command2() {
|
|
45665
|
-
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.
|
|
45635
|
+
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.5.1").showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`").help("help", "Show usage via `git stack help`").argv;
|
|
45666
45636
|
}
|
|
45667
45637
|
var GlobalOptions = {
|
|
45668
45638
|
verbose: {
|
|
@@ -45694,7 +45664,11 @@ var DefaultOptions = {
|
|
|
45694
45664
|
verify: {
|
|
45695
45665
|
type: "boolean",
|
|
45696
45666
|
default: true,
|
|
45697
|
-
description:
|
|
45667
|
+
description: [
|
|
45668
|
+
"Run git hooks such as pre-commit and pre-push",
|
|
45669
|
+
"Disable with --no-verify"
|
|
45670
|
+
].join(`
|
|
45671
|
+
`)
|
|
45698
45672
|
},
|
|
45699
45673
|
update: {
|
|
45700
45674
|
type: "boolean",
|
|
@@ -45705,7 +45679,11 @@ var DefaultOptions = {
|
|
|
45705
45679
|
branch: {
|
|
45706
45680
|
type: "string",
|
|
45707
45681
|
alias: ["b"],
|
|
45708
|
-
description:
|
|
45682
|
+
description: [
|
|
45683
|
+
"Set the master branch name, defaults to 'origin/master'",
|
|
45684
|
+
"(or 'origin/main' if 'origin/master' is not found)"
|
|
45685
|
+
].join(`
|
|
45686
|
+
`)
|
|
45709
45687
|
},
|
|
45710
45688
|
draft: {
|
|
45711
45689
|
type: "boolean",
|
|
@@ -45718,10 +45696,19 @@ var DefaultOptions = {
|
|
|
45718
45696
|
default: "",
|
|
45719
45697
|
description: "Prefix for generated branch names, e.g. dev/magus/"
|
|
45720
45698
|
},
|
|
45699
|
+
"revise-sign": {
|
|
45700
|
+
type: "boolean",
|
|
45701
|
+
default: true,
|
|
45702
|
+
description: "Disable GPG signing for git revise with --no-revise-sign"
|
|
45703
|
+
},
|
|
45721
45704
|
template: {
|
|
45722
45705
|
type: "boolean",
|
|
45723
45706
|
default: true,
|
|
45724
|
-
description:
|
|
45707
|
+
description: [
|
|
45708
|
+
"Use automatic Github PR template, e.g. .github/pull_request_template.md",
|
|
45709
|
+
"Disable with --no-template"
|
|
45710
|
+
].join(`
|
|
45711
|
+
`)
|
|
45725
45712
|
},
|
|
45726
45713
|
"write-state-json": {
|
|
45727
45714
|
hidden: true,
|
package/package.json
CHANGED
package/src/app/App.tsx
CHANGED
|
@@ -61,13 +61,11 @@ export function App() {
|
|
|
61
61
|
}}
|
|
62
62
|
>
|
|
63
63
|
<VerboseDebugInfo>
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</RebaseCheck>
|
|
70
|
-
</DependencyCheck>
|
|
64
|
+
<RebaseCheck>
|
|
65
|
+
<CherryPickCheck>
|
|
66
|
+
<MaybeMain />
|
|
67
|
+
</CherryPickCheck>
|
|
68
|
+
</RebaseCheck>
|
|
71
69
|
</VerboseDebugInfo>
|
|
72
70
|
</AutoUpdate>
|
|
73
71
|
|
|
@@ -100,15 +98,17 @@ function MaybeMain() {
|
|
|
100
98
|
<React.Fragment>
|
|
101
99
|
{!argv.verbose ? null : <GithubApiError />}
|
|
102
100
|
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
<DependencyCheck>
|
|
102
|
+
<GatherMetadata>
|
|
103
|
+
<DirtyCheck>
|
|
104
|
+
<LocalCommitStatus>
|
|
105
|
+
<DetectInitialPR>
|
|
106
|
+
<Main />
|
|
107
|
+
</DetectInitialPR>
|
|
108
|
+
</LocalCommitStatus>
|
|
109
|
+
</DirtyCheck>
|
|
110
|
+
</GatherMetadata>
|
|
111
|
+
</DependencyCheck>
|
|
112
112
|
</React.Fragment>
|
|
113
113
|
);
|
|
114
114
|
}
|
|
@@ -15,14 +15,17 @@ import * as gh from "~/github/gh";
|
|
|
15
15
|
|
|
16
16
|
type Props = {
|
|
17
17
|
children: React.ReactNode;
|
|
18
|
+
disableGithubCli?: boolean;
|
|
19
|
+
disableGithubCliAuth?: boolean;
|
|
20
|
+
disableGitRevise?: boolean;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
export function DependencyCheck(props: Props) {
|
|
21
24
|
return (
|
|
22
25
|
<CheckGit>
|
|
23
|
-
<CheckGithubCli>
|
|
24
|
-
<CheckGithubCliAuth>
|
|
25
|
-
<CheckGitRevise>
|
|
26
|
+
<CheckGithubCli {...props}>
|
|
27
|
+
<CheckGithubCliAuth {...props}>
|
|
28
|
+
<CheckGitRevise {...props}>
|
|
26
29
|
{/* force line break */}
|
|
27
30
|
{props.children}
|
|
28
31
|
</CheckGitRevise>
|
|
@@ -69,6 +72,10 @@ function CheckGit(props: Props) {
|
|
|
69
72
|
function CheckGithubCli(props: Props) {
|
|
70
73
|
const actions = Store.useActions();
|
|
71
74
|
|
|
75
|
+
if (props.disableGithubCli) {
|
|
76
|
+
return <>{props.children}</>;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
return (
|
|
73
80
|
<Await
|
|
74
81
|
fallback={
|
|
@@ -112,6 +119,10 @@ function CheckGithubCli(props: Props) {
|
|
|
112
119
|
function CheckGithubCliAuth(props: Props) {
|
|
113
120
|
const actions = Store.useActions();
|
|
114
121
|
|
|
122
|
+
if (props.disableGithubCliAuth) {
|
|
123
|
+
return <>{props.children}</>;
|
|
124
|
+
}
|
|
125
|
+
|
|
115
126
|
return (
|
|
116
127
|
<Await
|
|
117
128
|
fallback={
|
|
@@ -164,6 +175,10 @@ function CheckGithubCliAuth(props: Props) {
|
|
|
164
175
|
function CheckGitRevise(props: Props) {
|
|
165
176
|
const actions = Store.useActions();
|
|
166
177
|
|
|
178
|
+
if (props.disableGitRevise) {
|
|
179
|
+
return <>{props.children}</>;
|
|
180
|
+
}
|
|
181
|
+
|
|
167
182
|
return (
|
|
168
183
|
<Await
|
|
169
184
|
fallback={
|
package/src/app/SyncGithub.tsx
CHANGED
|
@@ -35,13 +35,6 @@ async function run() {
|
|
|
35
35
|
const commit_range = sync_github.commit_range;
|
|
36
36
|
const rebase_group_index = sync_github.rebase_group_index;
|
|
37
37
|
|
|
38
|
-
// immediately register abort_handler in case of ctrl+c exit
|
|
39
|
-
actions.register_abort_handler(async function abort_sync_github() {
|
|
40
|
-
actions.output(<Ink.Text color={colors.red}>🚨 Abort</Ink.Text>);
|
|
41
|
-
handle_exit();
|
|
42
|
-
return 17;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
38
|
let DEFAULT_PR_BODY = "";
|
|
46
39
|
if (state.pr_template_body) {
|
|
47
40
|
DEFAULT_PR_BODY = state.pr_template_body;
|
|
@@ -52,13 +45,10 @@ async function run() {
|
|
|
52
45
|
// for all push targets in push_group_list
|
|
53
46
|
// things that can be done in parallel are grouped by numbers
|
|
54
47
|
//
|
|
55
|
-
// -----------------------------------
|
|
56
|
-
// 1 (before_push) temp mark draft
|
|
57
48
|
// --------------------------------------
|
|
58
|
-
//
|
|
49
|
+
// 1 push simultaneously to github
|
|
59
50
|
// --------------------------------------
|
|
60
51
|
// 2 create PR / edit PR
|
|
61
|
-
// 2 (after_push) undo temp mark draft
|
|
62
52
|
// --------------------------------------
|
|
63
53
|
|
|
64
54
|
try {
|
|
@@ -170,25 +160,10 @@ async function run() {
|
|
|
170
160
|
|
|
171
161
|
invariant(group.base, "group.base must exist");
|
|
172
162
|
|
|
173
|
-
// we may temporarily mark PR as a draft before editing it
|
|
174
|
-
// if it is not already a draft PR, to avoid notification spam
|
|
175
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
176
|
-
|
|
177
163
|
// before pushing reset base to master temporarily
|
|
178
164
|
// avoid accidentally pointing to orphaned parent commit
|
|
179
165
|
// should hopefully fix issues where a PR includes a bunch of commits after pushing
|
|
180
166
|
if (group.pr) {
|
|
181
|
-
if (!group.pr.isDraft) {
|
|
182
|
-
is_temp_draft = true;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (is_temp_draft) {
|
|
186
|
-
await github.pr_draft({
|
|
187
|
-
branch: group.id,
|
|
188
|
-
draft: true,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
167
|
await github.pr_edit({
|
|
193
168
|
branch: group.id,
|
|
194
169
|
base: master_branch,
|
|
@@ -214,18 +189,6 @@ async function run() {
|
|
|
214
189
|
selected_url,
|
|
215
190
|
}),
|
|
216
191
|
});
|
|
217
|
-
|
|
218
|
-
// we may temporarily mark PR as a draft before editing it
|
|
219
|
-
// if it is not already a draft PR, to avoid notification spam
|
|
220
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
221
|
-
|
|
222
|
-
if (is_temp_draft) {
|
|
223
|
-
// mark pr as ready for review again
|
|
224
|
-
await github.pr_draft({
|
|
225
|
-
branch: group.id,
|
|
226
|
-
draft: false,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
192
|
} else {
|
|
230
193
|
// create pr in github
|
|
231
194
|
const pr_url = await github.pr_create({
|
|
@@ -279,28 +242,6 @@ async function run() {
|
|
|
279
242
|
});
|
|
280
243
|
}
|
|
281
244
|
}
|
|
282
|
-
|
|
283
|
-
function handle_exit() {
|
|
284
|
-
actions.output(<Ink.Text color={colors.yellow}>Restoring PR state…</Ink.Text>);
|
|
285
|
-
|
|
286
|
-
for (const group of push_group_list) {
|
|
287
|
-
// we may temporarily mark PR as a draft before editing it
|
|
288
|
-
// if it is not already a draft PR, to avoid notification spam
|
|
289
|
-
let is_temp_draft = !group.pr?.isDraft;
|
|
290
|
-
|
|
291
|
-
// restore PR to non-draft state
|
|
292
|
-
if (is_temp_draft) {
|
|
293
|
-
github
|
|
294
|
-
.pr_draft({
|
|
295
|
-
branch: group.id,
|
|
296
|
-
draft: false,
|
|
297
|
-
})
|
|
298
|
-
.catch(actions.error);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
actions.output(<Ink.Text color={colors.yellow}>Restored PR state.</Ink.Text>);
|
|
303
|
-
}
|
|
304
245
|
}
|
|
305
246
|
|
|
306
247
|
type CommitMetadataGroup = CommitMetadata.CommitRange["group_list"][number];
|
package/src/command.ts
CHANGED
|
@@ -79,7 +79,11 @@ const DefaultOptions = {
|
|
|
79
79
|
"verify": {
|
|
80
80
|
type: "boolean",
|
|
81
81
|
default: true,
|
|
82
|
-
description:
|
|
82
|
+
description: [
|
|
83
|
+
// force line break
|
|
84
|
+
"Run git hooks such as pre-commit and pre-push",
|
|
85
|
+
"Disable with --no-verify",
|
|
86
|
+
].join("\n"),
|
|
83
87
|
},
|
|
84
88
|
|
|
85
89
|
"update": {
|
|
@@ -92,8 +96,11 @@ const DefaultOptions = {
|
|
|
92
96
|
"branch": {
|
|
93
97
|
type: "string",
|
|
94
98
|
alias: ["b"],
|
|
95
|
-
description:
|
|
96
|
-
|
|
99
|
+
description: [
|
|
100
|
+
// force line break
|
|
101
|
+
"Set the master branch name, defaults to 'origin/master'",
|
|
102
|
+
"(or 'origin/main' if 'origin/master' is not found)",
|
|
103
|
+
].join("\n"),
|
|
97
104
|
},
|
|
98
105
|
|
|
99
106
|
"draft": {
|
|
@@ -109,11 +116,20 @@ const DefaultOptions = {
|
|
|
109
116
|
description: "Prefix for generated branch names, e.g. dev/magus/",
|
|
110
117
|
},
|
|
111
118
|
|
|
119
|
+
"revise-sign": {
|
|
120
|
+
type: "boolean",
|
|
121
|
+
default: true,
|
|
122
|
+
description: "Disable GPG signing for git revise with --no-revise-sign",
|
|
123
|
+
},
|
|
124
|
+
|
|
112
125
|
"template": {
|
|
113
126
|
type: "boolean",
|
|
114
127
|
default: true,
|
|
115
|
-
description:
|
|
116
|
-
|
|
128
|
+
description: [
|
|
129
|
+
// force line break
|
|
130
|
+
"Use automatic Github PR template, e.g. .github/pull_request_template.md",
|
|
131
|
+
"Disable with --no-template",
|
|
132
|
+
].join("\n"),
|
|
117
133
|
},
|
|
118
134
|
|
|
119
135
|
"write-state-json": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
+
import { Store } from "~/app/Store";
|
|
4
5
|
import * as Metadata from "~/core/Metadata";
|
|
5
6
|
import { cli } from "~/core/cli";
|
|
6
7
|
import { get_tmp_dir } from "~/core/get_tmp_dir";
|
|
@@ -106,6 +107,9 @@ GitReviseTodo.todo = function todo(args: CommitListArgs) {
|
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
GitReviseTodo.execute = async function grt_execute(args: ExecuteArgs) {
|
|
110
|
+
const argv = Store.getState().argv;
|
|
111
|
+
const actions = Store.getState().actions;
|
|
112
|
+
|
|
109
113
|
// replaced at build time with literal contents of `scripts/git-sequence-editor.sh`
|
|
110
114
|
const GIT_SEQUENCE_EDITOR_SCRIPT = process.env.GIT_SEQUENCE_EDITOR_SCRIPT;
|
|
111
115
|
invariant(GIT_SEQUENCE_EDITOR_SCRIPT, "GIT_SEQUENCE_EDITOR_SCRIPT must exist");
|
|
@@ -126,13 +130,31 @@ GitReviseTodo.execute = async function grt_execute(args: ExecuteArgs) {
|
|
|
126
130
|
`GIT_EDITOR="${tmp_git_sequence_editor_path}"`,
|
|
127
131
|
`GIT_REVISE_TODO="${tmp_path_git_revise_todo}"`,
|
|
128
132
|
`git`,
|
|
129
|
-
`revise --edit -i ${args.rebase_merge_base}`,
|
|
130
133
|
];
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
if (!argv["revise-sign"]) {
|
|
136
|
+
command.push(...["-c", "commit.gpgsign=false"]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
command.push(`revise --edit -i ${args.rebase_merge_base}`);
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
// `ignore` hides output which helps prevent scrollback clear
|
|
143
|
+
// `pipe` helps see failures when git revise fails
|
|
144
|
+
// https://github.com/magus/git-stack-cli/commit/f9f10e3ac3cd9a35ee75d3e0851a48391967a23f
|
|
145
|
+
await cli(command, { stdio: ["pipe", "pipe", "pipe"] });
|
|
146
|
+
} catch (err) {
|
|
147
|
+
if (err instanceof Error) {
|
|
148
|
+
actions.error(err.message);
|
|
149
|
+
if (err.message.includes("gpg failed to sign commit")) {
|
|
150
|
+
actions.error("\n\n");
|
|
151
|
+
actions.error("🚨 git revise failed to sign commit");
|
|
152
|
+
actions.error("💡 Try again with `--no-revise-sign`?");
|
|
153
|
+
actions.error("\n\n");
|
|
154
|
+
actions.exit(21);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
136
158
|
|
|
137
159
|
// cleanup tmp_git_sequence_editor_path
|
|
138
160
|
await safe_rm(tmp_git_sequence_editor_path);
|