gh-stack 0.2.1 → 0.2.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.
- package/package.json +1 -1
- package/src/commands/submit.ts +41 -10
package/package.json
CHANGED
package/src/commands/submit.ts
CHANGED
|
@@ -20,15 +20,19 @@ for branches that don't have them and updating stack visualization
|
|
|
20
20
|
in all PR descriptions. Idempotent — safe to run repeatedly.
|
|
21
21
|
|
|
22
22
|
OPTIONS
|
|
23
|
-
-d, --draft
|
|
24
|
-
-n, --no-edit
|
|
25
|
-
|
|
23
|
+
-d, --draft Create new PRs as drafts
|
|
24
|
+
-n, --no-edit Don't prompt for PR titles (auto-generate from branch name)
|
|
25
|
+
-t, --title <title> PR title for new PRs (skips prompt)
|
|
26
|
+
-b, --body <body> PR body/description for new PRs
|
|
27
|
+
--body-file <f> Read PR body from a file
|
|
28
|
+
--dry-run Show what would happen without doing anything
|
|
26
29
|
|
|
27
30
|
EXAMPLES
|
|
28
|
-
gh-stack submit
|
|
29
|
-
gh-stack submit -n
|
|
30
|
-
gh-stack submit
|
|
31
|
-
gh-stack submit --
|
|
31
|
+
gh-stack submit # Push + create PRs interactively
|
|
32
|
+
gh-stack submit -n # Push + create PRs with auto-titles
|
|
33
|
+
gh-stack submit -t "My PR" -b "Description" # Explicit title and body
|
|
34
|
+
gh-stack submit --draft # Create new PRs as drafts
|
|
35
|
+
gh-stack submit --dry-run # Preview what would happen
|
|
32
36
|
`;
|
|
33
37
|
|
|
34
38
|
/**
|
|
@@ -79,7 +83,32 @@ export default async function submit(args: string[]): Promise<void> {
|
|
|
79
83
|
|
|
80
84
|
const draftFlag = args.includes("--draft") || args.includes("-d");
|
|
81
85
|
const dryRun = args.includes("--dry-run");
|
|
82
|
-
|
|
86
|
+
|
|
87
|
+
// Parse value flags
|
|
88
|
+
let titleFlag: string | undefined;
|
|
89
|
+
let bodyFlag: string | undefined;
|
|
90
|
+
let bodyFileFlag: string | undefined;
|
|
91
|
+
for (let i = 0; i < args.length; i++) {
|
|
92
|
+
if ((args[i] === "--title" || args[i] === "-t") && args[i + 1]) {
|
|
93
|
+
titleFlag = args[++i];
|
|
94
|
+
} else if ((args[i] === "--body" || args[i] === "-b") && args[i + 1]) {
|
|
95
|
+
bodyFlag = args[++i];
|
|
96
|
+
} else if (args[i] === "--body-file" && args[i + 1]) {
|
|
97
|
+
bodyFileFlag = args[++i];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Resolve body from file if provided
|
|
102
|
+
if (bodyFileFlag && !bodyFlag) {
|
|
103
|
+
try {
|
|
104
|
+
bodyFlag = await Bun.file(bodyFileFlag).text();
|
|
105
|
+
} catch {
|
|
106
|
+
p.cancel(`Could not read body file: ${bodyFileFlag}`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const noEdit = args.includes("--no-edit") || args.includes("-n") || isAutoYes() || !!titleFlag;
|
|
83
112
|
|
|
84
113
|
const meta = await ensureMetadata();
|
|
85
114
|
const branch = await git.currentBranch();
|
|
@@ -166,7 +195,7 @@ export default async function submit(args: string[]): Promise<void> {
|
|
|
166
195
|
}
|
|
167
196
|
} else {
|
|
168
197
|
// ── Create new PR ──
|
|
169
|
-
const defaultTitle = branchToTitle(branchName);
|
|
198
|
+
const defaultTitle = titleFlag || branchToTitle(branchName);
|
|
170
199
|
let title = defaultTitle;
|
|
171
200
|
|
|
172
201
|
if (!noEdit && !dryRun) {
|
|
@@ -182,6 +211,8 @@ export default async function submit(args: string[]): Promise<void> {
|
|
|
182
211
|
title = (input as string).trim() || defaultTitle;
|
|
183
212
|
}
|
|
184
213
|
|
|
214
|
+
const body = bodyFlag ?? "";
|
|
215
|
+
|
|
185
216
|
if (dryRun) {
|
|
186
217
|
p.log.step(
|
|
187
218
|
`${pc.dim("create")} PR for ${branchName} → ${parentBranch} "${title}"${draftFlag ? " (draft)" : ""}`,
|
|
@@ -201,7 +232,7 @@ export default async function submit(args: string[]): Promise<void> {
|
|
|
201
232
|
"--title",
|
|
202
233
|
title,
|
|
203
234
|
"--body",
|
|
204
|
-
|
|
235
|
+
body,
|
|
205
236
|
];
|
|
206
237
|
if (draftFlag) ghArgs.push("--draft");
|
|
207
238
|
|