git-stack-cli 1.11.2 → 1.11.4
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/README.md +20 -1
- package/dist/cjs/index.cjs +17 -5
- package/package.json +1 -1
- package/scripts/release-npm.ts +7 -0
- package/src/app/DetectInitialPR.tsx +2 -1
- package/src/app/ManualRebase.tsx +10 -0
- package/src/core/github.tsx +10 -5
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Demo
|
|
15
15
|
|
|
16
|
-
> <img src="https://github.com/magus/git-multi-diff-playground/assets/290084/069c304b-80cb-49a9-9dc6-4ed3b061a5bc">
|
|
16
|
+
> <img alt="git stack demo" src="https://github.com/magus/git-multi-diff-playground/assets/290084/069c304b-80cb-49a9-9dc6-4ed3b061a5bc">
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -54,6 +54,25 @@ git stack --no-verify # skip git hooks such as pre-commit and pre-push
|
|
|
54
54
|
git stack help # print a table of all CLI arguments
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Editing existing commits and pull requests
|
|
58
|
+
|
|
59
|
+
Sometimes you want to add changes to an existing commit or pull request.
|
|
60
|
+
With `git-stack` this is as simple as amending the commit.
|
|
61
|
+
|
|
62
|
+
1. `git add` your changes to the stage
|
|
63
|
+
2. `git stack log` to find the relative commit number you want to amend
|
|
64
|
+
3. `git stack fixup <number>` to amend the specific commit with your staged changes.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git add -p
|
|
68
|
+
git stack log
|
|
69
|
+
git stack fixup 2
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> <img alt="git stack fixup demo" src="https://github.com/user-attachments/assets/2cdfaa5b-00be-4ed3-8bed-4a24c412979b">
|
|
73
|
+
|
|
74
|
+
Running `git stack` afterward will update any existing pull requests with your changes.
|
|
75
|
+
|
|
57
76
|
## Why?
|
|
58
77
|
|
|
59
78
|
The goal of `git stack` is to combine the **simplicity of developing in a single branch** in order to **preserve your commit history** while also **grouping commits into pull requests for code review**.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -29774,9 +29774,12 @@ async function pr_create(args) {
|
|
|
29774
29774
|
return cli_result.stdout;
|
|
29775
29775
|
}
|
|
29776
29776
|
async function pr_edit(args) {
|
|
29777
|
-
const
|
|
29778
|
-
|
|
29779
|
-
|
|
29777
|
+
const command_parts = [`gh pr edit ${args.branch} --base ${args.base}`];
|
|
29778
|
+
if (args.body) {
|
|
29779
|
+
command_parts.push(`--body-file="${body_file(args.body)}"`);
|
|
29780
|
+
}
|
|
29781
|
+
const command = command_parts.join(" ");
|
|
29782
|
+
const cli_result = await cli(command);
|
|
29780
29783
|
if (cli_result.code !== 0) {
|
|
29781
29784
|
handle_error(cli_result.output);
|
|
29782
29785
|
}
|
|
@@ -30160,7 +30163,7 @@ function DetectInitialPR(props) {
|
|
|
30160
30163
|
if (!has_existing_metadata) {
|
|
30161
30164
|
// check for pr with matching branch name to initialize group
|
|
30162
30165
|
const pr = await pr_status(branch_name);
|
|
30163
|
-
if (pr) {
|
|
30166
|
+
if (pr && pr.state === "OPEN") {
|
|
30164
30167
|
return patch({ status: "prompt", pr });
|
|
30165
30168
|
}
|
|
30166
30169
|
}
|
|
@@ -30908,6 +30911,15 @@ async function run$5() {
|
|
|
30908
30911
|
actions.output(reactExports.createElement(FormatText, { wrapper: reactExports.createElement(Text, { color: colors.yellow, wrap: "truncate-end" }), message: "Syncing {group}\u2026", values: {
|
|
30909
30912
|
group: (reactExports.createElement(Brackets, null, group.pr?.title || group.title || group.id)),
|
|
30910
30913
|
} }));
|
|
30914
|
+
// before pushing reset base to master temporarily
|
|
30915
|
+
// avoid accidentally pointing to orphaned parent commit
|
|
30916
|
+
// should hopefully fix issues where a PR includes a bunch of commits after pushing
|
|
30917
|
+
if (group.pr) {
|
|
30918
|
+
await pr_edit({
|
|
30919
|
+
branch: group.id,
|
|
30920
|
+
base: master_branch,
|
|
30921
|
+
});
|
|
30922
|
+
}
|
|
30911
30923
|
// push to origin since github requires commit shas to line up perfectly
|
|
30912
30924
|
const git_push_command = [`git push -f origin HEAD:${group.id}`];
|
|
30913
30925
|
if (argv.verify === false) {
|
|
@@ -37380,7 +37392,7 @@ async function command() {
|
|
|
37380
37392
|
.wrap(123)
|
|
37381
37393
|
// disallow unknown options
|
|
37382
37394
|
.strict()
|
|
37383
|
-
.version("1.11.
|
|
37395
|
+
.version("1.11.4" )
|
|
37384
37396
|
.showHidden("show-hidden", "Show hidden options via `git stack help --show-hidden`")
|
|
37385
37397
|
.help("help", "Show usage via `git stack help`")
|
|
37386
37398
|
.argv;
|
package/package.json
CHANGED
package/scripts/release-npm.ts
CHANGED
|
@@ -17,6 +17,13 @@ await fs.mkdir(DIST_DIR, { recursive: true });
|
|
|
17
17
|
|
|
18
18
|
process.chdir(PROJECT_DIR);
|
|
19
19
|
|
|
20
|
+
// require clean git status besides changes to package.json version
|
|
21
|
+
const git_status = await spawn.sync("git status --porcelain");
|
|
22
|
+
if (!/^M\s+package.json/.test(git_status.stdout)) {
|
|
23
|
+
console.error("please commit local changes before running release");
|
|
24
|
+
process.exit(4);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
const package_json = await file.read_json(
|
|
21
28
|
path.join(PROJECT_DIR, "package.json")
|
|
22
29
|
);
|
|
@@ -126,7 +126,8 @@ export function DetectInitialPR(props: Props) {
|
|
|
126
126
|
if (!has_existing_metadata) {
|
|
127
127
|
// check for pr with matching branch name to initialize group
|
|
128
128
|
const pr = await github.pr_status(branch_name);
|
|
129
|
-
|
|
129
|
+
|
|
130
|
+
if (pr && pr.state === "OPEN") {
|
|
130
131
|
return patch({ status: "prompt", pr });
|
|
131
132
|
}
|
|
132
133
|
}
|
package/src/app/ManualRebase.tsx
CHANGED
|
@@ -289,6 +289,16 @@ async function run() {
|
|
|
289
289
|
/>
|
|
290
290
|
);
|
|
291
291
|
|
|
292
|
+
// before pushing reset base to master temporarily
|
|
293
|
+
// avoid accidentally pointing to orphaned parent commit
|
|
294
|
+
// should hopefully fix issues where a PR includes a bunch of commits after pushing
|
|
295
|
+
if (group.pr) {
|
|
296
|
+
await github.pr_edit({
|
|
297
|
+
branch: group.id,
|
|
298
|
+
base: master_branch,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
292
302
|
// push to origin since github requires commit shas to line up perfectly
|
|
293
303
|
const git_push_command = [`git push -f origin HEAD:${group.id}`];
|
|
294
304
|
|
package/src/core/github.tsx
CHANGED
|
@@ -141,14 +141,19 @@ export async function pr_create(args: CreatePullRequestArgs) {
|
|
|
141
141
|
type EditPullRequestArgs = {
|
|
142
142
|
branch: string;
|
|
143
143
|
base: string;
|
|
144
|
-
body
|
|
144
|
+
body?: string;
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
export async function pr_edit(args: EditPullRequestArgs) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
const command_parts = [`gh pr edit ${args.branch} --base ${args.base}`];
|
|
149
|
+
|
|
150
|
+
if (args.body) {
|
|
151
|
+
command_parts.push(`--body-file="${body_file(args.body)}"`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const command = command_parts.join(" ");
|
|
155
|
+
|
|
156
|
+
const cli_result = await cli(command);
|
|
152
157
|
|
|
153
158
|
if (cli_result.code !== 0) {
|
|
154
159
|
handle_error(cli_result.output);
|