git-stack-cli 0.8.3 → 0.8.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.
|
@@ -69,8 +69,10 @@ async function gather_metadata() {
|
|
|
69
69
|
// https://github.com/magus/git-multi-diff-playground.git
|
|
70
70
|
const origin_url = (await cli(`git config --get remote.origin.url`)).stdout;
|
|
71
71
|
const repo_path = match_group(origin_url, RE.repo_path, "repo_path");
|
|
72
|
+
const repo_root = (await cli(`git rev-parse --show-toplevel`)).stdout;
|
|
72
73
|
Store.setState((state) => {
|
|
73
74
|
state.repo_path = repo_path;
|
|
75
|
+
state.repo_root = repo_root;
|
|
74
76
|
state.master_branch = master_branch;
|
|
75
77
|
state.head = head;
|
|
76
78
|
state.merge_base = merge_base;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import * as Ink from "ink";
|
|
3
4
|
import * as CommitMetadata from "../core/CommitMetadata.js";
|
|
4
5
|
import * as Metadata from "../core/Metadata.js";
|
|
@@ -21,13 +22,20 @@ async function run() {
|
|
|
21
22
|
const branch_name = state.branch_name;
|
|
22
23
|
const commit_range = state.commit_range;
|
|
23
24
|
const master_branch = state.master_branch;
|
|
25
|
+
const cwd = state.cwd;
|
|
26
|
+
const repo_root = state.repo_root;
|
|
24
27
|
invariant(argv, "argv must exist");
|
|
25
28
|
invariant(branch_name, "branch_name must exist");
|
|
26
29
|
invariant(commit_range, "commit_range must exist");
|
|
30
|
+
invariant(cwd, "cwd must exist");
|
|
31
|
+
invariant(repo_root, "repo_root must exist");
|
|
27
32
|
// always listen for SIGINT event and restore git state
|
|
28
33
|
process.once("SIGINT", handle_exit);
|
|
29
34
|
const temp_branch_name = `${branch_name}_${short_id()}`;
|
|
30
35
|
try {
|
|
36
|
+
// must perform rebase from repo root for applying git patch
|
|
37
|
+
process.chdir(repo_root);
|
|
38
|
+
await cli(`pwd`);
|
|
31
39
|
await cli(`git fetch --no-tags -v origin ${master_branch}:${master_branch}`);
|
|
32
40
|
const master_sha = (await cli(`git rev-parse ${master_branch}`)).stdout;
|
|
33
41
|
const rebase_merge_base = master_sha;
|
|
@@ -126,6 +134,12 @@ async function run() {
|
|
|
126
134
|
cli.sync(`git branch -D ${group.id}`, spawn_options);
|
|
127
135
|
}
|
|
128
136
|
}
|
|
137
|
+
// restore back to original dir
|
|
138
|
+
invariant(cwd, "cwd must exist");
|
|
139
|
+
if (fs.existsSync(cwd)) {
|
|
140
|
+
process.chdir(cwd);
|
|
141
|
+
}
|
|
142
|
+
cli.sync(`pwd`, spawn_options);
|
|
129
143
|
}
|
|
130
144
|
function handle_exit() {
|
|
131
145
|
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
package/dist/app/ManualRebase.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import * as Ink from "ink";
|
|
3
4
|
import * as CommitMetadata from "../core/CommitMetadata.js";
|
|
4
5
|
import * as Metadata from "../core/Metadata.js";
|
|
@@ -22,10 +23,14 @@ async function run(props) {
|
|
|
22
23
|
const branch_name = state.branch_name;
|
|
23
24
|
const merge_base = state.merge_base;
|
|
24
25
|
const commit_map = state.commit_map;
|
|
26
|
+
const cwd = state.cwd;
|
|
27
|
+
const repo_root = state.repo_root;
|
|
25
28
|
invariant(argv, "argv must exist");
|
|
26
29
|
invariant(branch_name, "branch_name must exist");
|
|
27
30
|
invariant(merge_base, "merge_base must exist");
|
|
28
31
|
invariant(commit_map, "commit_map must exist");
|
|
32
|
+
invariant(cwd, "cwd must exist");
|
|
33
|
+
invariant(repo_root, "repo_root must exist");
|
|
29
34
|
// always listen for SIGINT event and restore git state
|
|
30
35
|
process.once("SIGINT", handle_exit);
|
|
31
36
|
const temp_branch_name = `${branch_name}_${short_id()}`;
|
|
@@ -48,6 +53,9 @@ async function run(props) {
|
|
|
48
53
|
break;
|
|
49
54
|
}
|
|
50
55
|
try {
|
|
56
|
+
// must perform rebase from repo root for applying git patch
|
|
57
|
+
process.chdir(repo_root);
|
|
58
|
+
await cli(`pwd`);
|
|
51
59
|
// create temporary branch based on merge base
|
|
52
60
|
await cli(`git checkout -b ${temp_branch_name} ${rebase_merge_base}`);
|
|
53
61
|
const pr_url_list = commit_range.group_list.map(get_group_url);
|
|
@@ -188,6 +196,12 @@ async function run(props) {
|
|
|
188
196
|
cli.sync(`git branch -D ${group.id}`, spawn_options);
|
|
189
197
|
}
|
|
190
198
|
}
|
|
199
|
+
// restore back to original dir
|
|
200
|
+
invariant(cwd, "cwd must exist");
|
|
201
|
+
if (fs.existsSync(cwd)) {
|
|
202
|
+
process.chdir(cwd);
|
|
203
|
+
}
|
|
204
|
+
cli.sync(`pwd`, spawn_options);
|
|
191
205
|
}
|
|
192
206
|
function handle_exit() {
|
|
193
207
|
actions.output(React.createElement(Ink.Text, { color: colors.yellow },
|
package/dist/app/Store.js
CHANGED