git-stack-cli 2.9.2 → 2.9.3
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 +75 -75
- package/package.json +1 -1
- package/src/app/App.tsx +13 -8
- package/src/app/FetchPullRequests.tsx +40 -0
- package/src/app/Store.tsx +1 -1
- package/src/app/SyncGithub.tsx +13 -2
- package/src/core/CommitMetadata.ts +17 -22
package/package.json
CHANGED
package/src/app/App.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { CherryPickCheck } from "~/app/CherryPickCheck";
|
|
|
5
5
|
import { DependencyCheck } from "~/app/DependencyCheck";
|
|
6
6
|
import { DetectInitialPR } from "~/app/DetectInitialPR";
|
|
7
7
|
import { DirtyCheck } from "~/app/DirtyCheck";
|
|
8
|
+
import { FetchPullRequests } from "~/app/FetchPullRequests";
|
|
8
9
|
import { GatherMetadata } from "~/app/GatherMetadata";
|
|
9
10
|
import { GithubApiError } from "~/app/GithubApiError";
|
|
10
11
|
import { HandleCtrlCSigint } from "~/app/HandleCtrlCSigint";
|
|
@@ -100,9 +101,11 @@ function MaybeMain() {
|
|
|
100
101
|
<DependencyCheck>
|
|
101
102
|
<DirtyCheck>
|
|
102
103
|
<GatherMetadata>
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
104
|
+
<FetchPullRequests>
|
|
105
|
+
<LocalCommitStatus>
|
|
106
|
+
<Rebase />
|
|
107
|
+
</LocalCommitStatus>
|
|
108
|
+
</FetchPullRequests>
|
|
106
109
|
</GatherMetadata>
|
|
107
110
|
</DirtyCheck>
|
|
108
111
|
</DependencyCheck>
|
|
@@ -117,11 +120,13 @@ function MaybeMain() {
|
|
|
117
120
|
<DirtyCheck>
|
|
118
121
|
<GatherMetadata>
|
|
119
122
|
<RequireBranch>
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
<FetchPullRequests>
|
|
124
|
+
<LocalCommitStatus>
|
|
125
|
+
<DetectInitialPR>
|
|
126
|
+
<Main />
|
|
127
|
+
</DetectInitialPR>
|
|
128
|
+
</LocalCommitStatus>
|
|
129
|
+
</FetchPullRequests>
|
|
125
130
|
</RequireBranch>
|
|
126
131
|
</GatherMetadata>
|
|
127
132
|
</DirtyCheck>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import * as Ink from "ink-cjs";
|
|
4
|
+
|
|
5
|
+
import { Await } from "~/app/Await";
|
|
6
|
+
import { Store } from "~/app/Store";
|
|
7
|
+
import { colors } from "~/core/colors";
|
|
8
|
+
import * as github from "~/core/github";
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function FetchPullRequests(props: Props) {
|
|
15
|
+
const fallback = <Ink.Text color={colors.yellow}>Fetching pull requests…</Ink.Text>;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Await fallback={fallback} function={run}>
|
|
19
|
+
{props.children}
|
|
20
|
+
</Await>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function run() {
|
|
25
|
+
const actions = Store.getState().actions;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// gather all open prs in repo at once
|
|
29
|
+
// cheaper query to populate cache
|
|
30
|
+
await github.pr_list();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
actions.error("Unable to fetch pull requests.");
|
|
33
|
+
|
|
34
|
+
if (err instanceof Error) {
|
|
35
|
+
actions.error(err.message);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
actions.exit(24);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/app/Store.tsx
CHANGED
package/src/app/SyncGithub.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { colors } from "~/core/colors";
|
|
|
13
13
|
import * as github from "~/core/github";
|
|
14
14
|
import { invariant } from "~/core/invariant";
|
|
15
15
|
import { safe_exists } from "~/core/safe_exists";
|
|
16
|
+
import { sleep } from "~/core/sleep";
|
|
16
17
|
|
|
17
18
|
import type * as CommitMetadata from "~/core/CommitMetadata";
|
|
18
19
|
|
|
@@ -159,16 +160,26 @@ async function run() {
|
|
|
159
160
|
|
|
160
161
|
actions.unregister_abort_handler();
|
|
161
162
|
|
|
163
|
+
// invalidate cache for PRs we pushed
|
|
162
164
|
actions.set((state) => {
|
|
163
|
-
// invalidate cache for PRs we pushed
|
|
164
165
|
for (const group of push_group_list) {
|
|
165
166
|
if (group.pr) {
|
|
166
167
|
delete state.pr[group.pr.headRefName];
|
|
167
168
|
delete state.cache_pr_diff[group.pr.number];
|
|
168
169
|
}
|
|
169
170
|
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// wait a bit for github to settle after push / edits above
|
|
174
|
+
// we github.pr_list returns outdated information if called too quickly
|
|
175
|
+
await sleep(400);
|
|
170
176
|
|
|
171
|
-
|
|
177
|
+
// gather all open prs in repo at once
|
|
178
|
+
// cheaper query to populate cache
|
|
179
|
+
await github.pr_list();
|
|
180
|
+
|
|
181
|
+
// move to next step
|
|
182
|
+
actions.set((state) => {
|
|
172
183
|
state.step = "post-rebase-status";
|
|
173
184
|
});
|
|
174
185
|
} catch (err) {
|
|
@@ -30,11 +30,9 @@ type CommitGroupMap = { [sha: string]: CommitRangeGroup };
|
|
|
30
30
|
export async function range(commit_group_map?: CommitGroupMap) {
|
|
31
31
|
const DEBUG = process.env.DEV && false;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const master_branch = Store.getState().master_branch;
|
|
33
|
+
const state = Store.getState();
|
|
34
|
+
const actions = state.actions;
|
|
35
|
+
const master_branch = state.master_branch;
|
|
38
36
|
const master_branch_name = master_branch.replace(/^origin\//, "");
|
|
39
37
|
const commit_list = await git.get_commits(`${master_branch}..HEAD`);
|
|
40
38
|
|
|
@@ -167,18 +165,16 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
167
165
|
// console.debug(" ", "group.base", group.base);
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
console.debug({ group });
|
|
172
|
-
}
|
|
168
|
+
actions.json({ group });
|
|
173
169
|
|
|
174
170
|
if (!group.pr) {
|
|
175
171
|
group.dirty = true;
|
|
176
172
|
} else {
|
|
177
173
|
if (group.pr.baseRefName !== group.base) {
|
|
178
|
-
|
|
174
|
+
actions.debug("PR_BASEREF_MISMATCH");
|
|
179
175
|
group.dirty = true;
|
|
180
176
|
} else if (group.master_base) {
|
|
181
|
-
|
|
177
|
+
actions.debug("MASTER_BASE_DIFF_COMPARE");
|
|
182
178
|
|
|
183
179
|
// special case
|
|
184
180
|
// master_base groups cannot be compared by commit sha
|
|
@@ -191,9 +187,7 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
191
187
|
let diff_local = await git.get_diff(group.commits);
|
|
192
188
|
diff_local = normalize_diff(diff_local);
|
|
193
189
|
|
|
194
|
-
|
|
195
|
-
console.debug({ diff_local, diff_github });
|
|
196
|
-
}
|
|
190
|
+
actions.json({ diff_local, diff_github });
|
|
197
191
|
|
|
198
192
|
// find the first differing character index
|
|
199
193
|
let compare_length = Math.max(diff_github.length, diff_local.length);
|
|
@@ -220,11 +214,11 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
220
214
|
diff_local = JSON.stringify(diff_local).slice(1, -1);
|
|
221
215
|
|
|
222
216
|
let pointer_indent = " ".repeat(diff_index - start_index + 1);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
217
|
+
actions.debug(`⚠️ git diff mismatch`);
|
|
218
|
+
actions.debug(` ${pointer_indent}⌄`);
|
|
219
|
+
actions.debug(`diff_github …${diff_github}…`);
|
|
220
|
+
actions.debug(`diff_local …${diff_local}…`);
|
|
221
|
+
actions.debug(` ${pointer_indent}⌃`);
|
|
228
222
|
}
|
|
229
223
|
}
|
|
230
224
|
} else if (!group.master_base && previous_group && previous_group.master_base) {
|
|
@@ -245,10 +239,10 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
245
239
|
|
|
246
240
|
// compare all commits against pr commits
|
|
247
241
|
if (group.pr.commits.length !== all_commits.length) {
|
|
248
|
-
|
|
242
|
+
actions.debug("BOUNDARY_COMMIT_LENGTH_MISMATCH");
|
|
249
243
|
group.dirty = true;
|
|
250
244
|
} else {
|
|
251
|
-
|
|
245
|
+
actions.debug("BOUNDARY_COMMIT_SHA_COMPARISON");
|
|
252
246
|
for (let i = 0; i < group.pr.commits.length; i++) {
|
|
253
247
|
const pr_commit = group.pr.commits[i];
|
|
254
248
|
const local_commit = all_commits[i];
|
|
@@ -259,10 +253,10 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
259
253
|
}
|
|
260
254
|
}
|
|
261
255
|
} else if (group.pr.commits.length !== group.commits.length) {
|
|
262
|
-
|
|
256
|
+
actions.debug("COMMIT_LENGTH_MISMATCH");
|
|
263
257
|
group.dirty = true;
|
|
264
258
|
} else {
|
|
265
|
-
|
|
259
|
+
actions.debug("COMMIT_SHA_COMPARISON");
|
|
266
260
|
// if we still haven't marked this dirty, check each commit
|
|
267
261
|
// comapre literal commit shas in group
|
|
268
262
|
for (let i = 0; i < group.pr.commits.length; i++) {
|
|
@@ -270,6 +264,7 @@ export async function range(commit_group_map?: CommitGroupMap) {
|
|
|
270
264
|
const local_commit = group.commits[i];
|
|
271
265
|
|
|
272
266
|
if (pr_commit.oid !== local_commit.sha) {
|
|
267
|
+
actions.json({ pr_commit, local_commit });
|
|
273
268
|
group.dirty = true;
|
|
274
269
|
}
|
|
275
270
|
}
|