git-stack-cli 1.7.0 → 1.8.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 +37 -28
- package/package.json +1 -1
- package/src/app/ManualRebase.tsx +1 -0
- package/src/app/PreManualRebase.tsx +35 -27
- package/src/command.ts +7 -0
- package/src/core/github.tsx +7 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -27347,7 +27347,11 @@ async function pr_status(branch) {
|
|
|
27347
27347
|
}
|
|
27348
27348
|
async function pr_create(args) {
|
|
27349
27349
|
const title = safe_quote(args.title);
|
|
27350
|
-
|
|
27350
|
+
let command = `gh pr create --fill --head ${args.branch} --base ${args.base} --title="${title}" --body="${args.body}"`;
|
|
27351
|
+
if (args.draft) {
|
|
27352
|
+
command += " --draft";
|
|
27353
|
+
}
|
|
27354
|
+
const cli_result = await cli(command);
|
|
27351
27355
|
if (cli_result.code !== 0) {
|
|
27352
27356
|
handle_error(cli_result.output);
|
|
27353
27357
|
return null;
|
|
@@ -28175,6 +28179,7 @@ echo "$GIT_REVISE_TODO" > "$git_revise_todo_path"
|
|
|
28175
28179
|
base: group.base,
|
|
28176
28180
|
title: group.title,
|
|
28177
28181
|
body: DEFAULT_PR_BODY,
|
|
28182
|
+
draft: argv.draft,
|
|
28178
28183
|
});
|
|
28179
28184
|
if (!pr_url) {
|
|
28180
28185
|
throw new Error("unable to create pr");
|
|
@@ -28487,25 +28492,26 @@ async function run$1() {
|
|
|
28487
28492
|
state.step = "manual-rebase";
|
|
28488
28493
|
});
|
|
28489
28494
|
}
|
|
28490
|
-
|
|
28491
|
-
let pr_templates = [];
|
|
28492
|
-
if (fs.existsSync(template_pr_template(repo_root))) {
|
|
28493
|
-
pr_templates = fs.readdirSync(template_pr_template(repo_root));
|
|
28494
|
-
}
|
|
28495
|
+
let pr_template_body = null;
|
|
28495
28496
|
// look for pull request template
|
|
28496
28497
|
// https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
|
|
28497
28498
|
// ./.github/pull_request_template.md
|
|
28498
28499
|
// ./pull_request_template.md
|
|
28499
28500
|
// ./docs/pull_request_template.md
|
|
28500
|
-
|
|
28501
|
-
|
|
28502
|
-
|
|
28503
|
-
|
|
28504
|
-
|
|
28505
|
-
|
|
28501
|
+
for (const key of PR_TEMPLATE_KEY_LIST) {
|
|
28502
|
+
const pr_template_fn = PR_TEMPLATE[key];
|
|
28503
|
+
if (fs.existsSync(pr_template_fn(repo_root))) {
|
|
28504
|
+
pr_template_body = fs.readFileSync(pr_template_fn(repo_root), "utf-8");
|
|
28505
|
+
actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow }), message: "Using PR template {pr_filepath}", values: {
|
|
28506
|
+
pr_filepath: reactExports.createElement(Brackets, null, pr_template_fn("")),
|
|
28507
|
+
} }));
|
|
28508
|
+
break;
|
|
28509
|
+
}
|
|
28506
28510
|
}
|
|
28507
|
-
|
|
28508
|
-
|
|
28511
|
+
// ./.github/PULL_REQUEST_TEMPLATE/*.md
|
|
28512
|
+
let pr_templates = [];
|
|
28513
|
+
if (fs.existsSync(PR_TEMPLATE.TemplateDir(repo_root))) {
|
|
28514
|
+
pr_templates = fs.readdirSync(PR_TEMPLATE.TemplateDir(repo_root));
|
|
28509
28515
|
}
|
|
28510
28516
|
// check if repo has multiple pr templates
|
|
28511
28517
|
actions.set((state) => {
|
|
@@ -28514,24 +28520,21 @@ async function run$1() {
|
|
|
28514
28520
|
if (pr_templates.length > 0) {
|
|
28515
28521
|
actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow }), message: "{count} queryable templates found under {dir}, but not supported.", values: {
|
|
28516
28522
|
count: (reactExports.createElement(Text, { color: colors.blue }, pr_templates.length)),
|
|
28517
|
-
dir: reactExports.createElement(Brackets, null,
|
|
28523
|
+
dir: reactExports.createElement(Brackets, null, PR_TEMPLATE.TemplateDir("")),
|
|
28518
28524
|
} }));
|
|
28519
28525
|
}
|
|
28520
28526
|
state.step = "manual-rebase";
|
|
28521
28527
|
});
|
|
28522
28528
|
}
|
|
28523
|
-
|
|
28524
|
-
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28528
|
-
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28532
|
-
function template_pr_template(repo_root) {
|
|
28533
|
-
return path.join(repo_root, ".github", "PULL_REQUEST_TEMPLATE");
|
|
28534
|
-
}
|
|
28529
|
+
// prettier-ignore
|
|
28530
|
+
const PR_TEMPLATE = Object.freeze({
|
|
28531
|
+
Github: (root) => path.join(root, ".github", "pull_request_template.md"),
|
|
28532
|
+
Root: (root) => path.join(root, "pull_request_template.md"),
|
|
28533
|
+
Docs: (root) => path.join(root, "docs", "pull_request_template.md"),
|
|
28534
|
+
TemplateDir: (root) => path.join(root, ".github", "PULL_REQUEST_TEMPLATE"),
|
|
28535
|
+
});
|
|
28536
|
+
// prettier-ignore
|
|
28537
|
+
const PR_TEMPLATE_KEY_LIST = Object.keys(PR_TEMPLATE);
|
|
28535
28538
|
|
|
28536
28539
|
function PreSelectCommitRanges() {
|
|
28537
28540
|
const actions = Store.useActions();
|
|
@@ -34517,6 +34520,12 @@ async function command() {
|
|
|
34517
34520
|
type: "string",
|
|
34518
34521
|
alias: ["b"],
|
|
34519
34522
|
description: 'Set the master branch name, defaults to "master" (or "main" if "master" is not found)',
|
|
34523
|
+
})
|
|
34524
|
+
.option("draft", {
|
|
34525
|
+
type: "boolean",
|
|
34526
|
+
alias: ["d"],
|
|
34527
|
+
default: false,
|
|
34528
|
+
description: "Open all PRs as drafts",
|
|
34520
34529
|
})
|
|
34521
34530
|
.option("write-state-json", {
|
|
34522
34531
|
hidden: true,
|
|
@@ -34541,7 +34550,7 @@ async function command() {
|
|
|
34541
34550
|
.wrap(123)
|
|
34542
34551
|
// disallow unknown options
|
|
34543
34552
|
.strict()
|
|
34544
|
-
.version("1.
|
|
34553
|
+
.version("1.8.0" )
|
|
34545
34554
|
.showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
|
|
34546
34555
|
.help("help", "Show usage via `git stack help`").argv);
|
|
34547
34556
|
}
|
package/package.json
CHANGED
package/src/app/ManualRebase.tsx
CHANGED
|
@@ -31,24 +31,37 @@ async function run() {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
let pr_templates: Array<string> = [];
|
|
36
|
-
if (fs.existsSync(template_pr_template(repo_root))) {
|
|
37
|
-
pr_templates = fs.readdirSync(template_pr_template(repo_root));
|
|
38
|
-
}
|
|
34
|
+
let pr_template_body: null | string = null;
|
|
39
35
|
|
|
40
36
|
// look for pull request template
|
|
41
37
|
// https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
|
|
42
38
|
// ./.github/pull_request_template.md
|
|
43
39
|
// ./pull_request_template.md
|
|
44
40
|
// ./docs/pull_request_template.md
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
for (const key of PR_TEMPLATE_KEY_LIST) {
|
|
42
|
+
const pr_template_fn = PR_TEMPLATE[key as keyof typeof PR_TEMPLATE];
|
|
43
|
+
|
|
44
|
+
if (fs.existsSync(pr_template_fn(repo_root))) {
|
|
45
|
+
pr_template_body = fs.readFileSync(pr_template_fn(repo_root), "utf-8");
|
|
46
|
+
|
|
47
|
+
actions.output(
|
|
48
|
+
<FormatText
|
|
49
|
+
wrapper={<Ink.Text color={colors.yellow} />}
|
|
50
|
+
message="Using PR template {pr_filepath}"
|
|
51
|
+
values={{
|
|
52
|
+
pr_filepath: <Brackets>{pr_template_fn("")}</Brackets>,
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ./.github/PULL_REQUEST_TEMPLATE/*.md
|
|
62
|
+
let pr_templates: Array<string> = [];
|
|
63
|
+
if (fs.existsSync(PR_TEMPLATE.TemplateDir(repo_root))) {
|
|
64
|
+
pr_templates = fs.readdirSync(PR_TEMPLATE.TemplateDir(repo_root));
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
// check if repo has multiple pr templates
|
|
@@ -65,7 +78,7 @@ async function run() {
|
|
|
65
78
|
count: (
|
|
66
79
|
<Ink.Text color={colors.blue}>{pr_templates.length}</Ink.Text>
|
|
67
80
|
),
|
|
68
|
-
dir: <Brackets>{
|
|
81
|
+
dir: <Brackets>{PR_TEMPLATE.TemplateDir("")}</Brackets>,
|
|
69
82
|
}}
|
|
70
83
|
/>
|
|
71
84
|
);
|
|
@@ -75,18 +88,13 @@ async function run() {
|
|
|
75
88
|
});
|
|
76
89
|
}
|
|
77
90
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
91
|
+
// prettier-ignore
|
|
92
|
+
const PR_TEMPLATE = Object.freeze({
|
|
93
|
+
Github: (root: string) => path.join(root, ".github", "pull_request_template.md"),
|
|
94
|
+
Root: (root: string) => path.join(root, "pull_request_template.md"),
|
|
95
|
+
Docs: (root: string) => path.join(root, "docs", "pull_request_template.md"),
|
|
96
|
+
TemplateDir: (root: string) => path.join(root, ".github", "PULL_REQUEST_TEMPLATE"),
|
|
97
|
+
});
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function template_pr_template(repo_root: string) {
|
|
91
|
-
return path.join(repo_root, ".github", "PULL_REQUEST_TEMPLATE");
|
|
92
|
-
}
|
|
99
|
+
// prettier-ignore
|
|
100
|
+
const PR_TEMPLATE_KEY_LIST = Object.keys(PR_TEMPLATE) as Array<keyof typeof PR_TEMPLATE>;
|
package/src/command.ts
CHANGED
|
@@ -71,6 +71,13 @@ export async function command() {
|
|
|
71
71
|
'Set the master branch name, defaults to "master" (or "main" if "master" is not found)',
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
+
.option("draft", {
|
|
75
|
+
type: "boolean",
|
|
76
|
+
alias: ["d"],
|
|
77
|
+
default: false,
|
|
78
|
+
description: "Open all PRs as drafts",
|
|
79
|
+
})
|
|
80
|
+
|
|
74
81
|
.option("write-state-json", {
|
|
75
82
|
hidden: true,
|
|
76
83
|
type: "boolean",
|
package/src/core/github.tsx
CHANGED
|
@@ -131,14 +131,18 @@ type CreatePullRequestArgs = {
|
|
|
131
131
|
base: string;
|
|
132
132
|
title: string;
|
|
133
133
|
body: string;
|
|
134
|
+
draft: boolean;
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
export async function pr_create(args: CreatePullRequestArgs) {
|
|
137
138
|
const title = safe_quote(args.title);
|
|
139
|
+
let command = `gh pr create --fill --head ${args.branch} --base ${args.base} --title="${title}" --body="${args.body}"`;
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
if (args.draft) {
|
|
142
|
+
command += " --draft";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const cli_result = await cli(command);
|
|
142
146
|
|
|
143
147
|
if (cli_result.code !== 0) {
|
|
144
148
|
handle_error(cli_result.output);
|