git-stack-cli 2.8.1 → 2.8.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/README.md +6 -0
- package/dist/js/index.js +65 -65
- package/package.json +1 -1
- package/src/app/GatherMetadata.test.tsx +33 -0
- package/src/app/GatherMetadata.tsx +12 -1
- package/src/app/PreManualRebase.tsx +39 -16
- package/src/app/SyncGithub.tsx +0 -2
- package/src/core/github.tsx +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { test, expect } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import * as GatherMetadata from "~/app/GatherMetadata";
|
|
4
|
+
|
|
5
|
+
test("invalid origin", () => {
|
|
6
|
+
const origin_url = "";
|
|
7
|
+
const repo_path = GatherMetadata.get_repo_path(origin_url);
|
|
8
|
+
expect(repo_path).toBe(null);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("https .git", () => {
|
|
12
|
+
const origin_url = "https://github.com/magus/git-multi-diff-playground.git";
|
|
13
|
+
const repo_path = GatherMetadata.get_repo_path(origin_url);
|
|
14
|
+
expect(repo_path).toBe("magus/git-multi-diff-playground");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("https without .git", () => {
|
|
18
|
+
const origin_url = "https://github.com/magus/git-multi-diff-playground";
|
|
19
|
+
const repo_path = GatherMetadata.get_repo_path(origin_url);
|
|
20
|
+
expect(repo_path).toBe("magus/git-multi-diff-playground");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("git@ .git", () => {
|
|
24
|
+
const origin_url = "git@github.com:magus/git-multi-diff-playground.git";
|
|
25
|
+
const repo_path = GatherMetadata.get_repo_path(origin_url);
|
|
26
|
+
expect(repo_path).toBe("magus/git-multi-diff-playground");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("git@ without .git", () => {
|
|
30
|
+
const origin_url = "git@github.com:magus/git-multi-diff-playground";
|
|
31
|
+
const repo_path = GatherMetadata.get_repo_path(origin_url);
|
|
32
|
+
expect(repo_path).toBe("magus/git-multi-diff-playground");
|
|
33
|
+
});
|
|
@@ -97,10 +97,21 @@ async function run() {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
export function get_repo_path(origin_url: string): null | string {
|
|
101
|
+
try {
|
|
102
|
+
return match_group(origin_url, RE.repo_path, "repo_path");
|
|
103
|
+
} catch {
|
|
104
|
+
// pass
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
100
109
|
const RE = {
|
|
101
110
|
// git@github.com:magus/git-multi-diff-playground.git
|
|
102
111
|
// https://github.com/magus/git-multi-diff-playground.git
|
|
103
|
-
|
|
112
|
+
// the .git suffix is optional for remote urls, and may not always be provided
|
|
113
|
+
// https://regex101.com/r/pICG7G/1
|
|
114
|
+
repo_path: /(?<repo_path>[^:^/]+\/[^/]+?)(\.git)?$/,
|
|
104
115
|
};
|
|
105
116
|
|
|
106
117
|
const BRANCH = {
|
|
@@ -39,10 +39,11 @@ async function run() {
|
|
|
39
39
|
// ./pull_request_template.md
|
|
40
40
|
// ./docs/pull_request_template.md
|
|
41
41
|
for (const key of PR_TEMPLATE_KEY_LIST) {
|
|
42
|
-
const pr_template_fn = PR_TEMPLATE[key
|
|
42
|
+
const pr_template_fn = PR_TEMPLATE[key];
|
|
43
|
+
const pr_template_file = pr_template_fn(repo_root);
|
|
43
44
|
|
|
44
|
-
if (await safe_exists(
|
|
45
|
-
pr_template_body = await fs.readFile(
|
|
45
|
+
if (await safe_exists(pr_template_file)) {
|
|
46
|
+
pr_template_body = await fs.readFile(pr_template_file, "utf-8");
|
|
46
47
|
|
|
47
48
|
actions.output(
|
|
48
49
|
<FormatText
|
|
@@ -58,10 +59,23 @@ async function run() {
|
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
// ./.github/PULL_REQUEST_TEMPLATE/*.md
|
|
62
62
|
let pr_templates: Array<string> = [];
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
let pr_dir: string = "";
|
|
64
|
+
|
|
65
|
+
// ./.github/PULL_REQUEST_TEMPLATE/*.md
|
|
66
|
+
pr_dir = PR_TEMPLATE.DirGithub(repo_root);
|
|
67
|
+
if (await safe_exists(pr_dir)) {
|
|
68
|
+
for (const filename of await fs.readdir(pr_dir)) {
|
|
69
|
+
pr_templates.push(path.join(pr_dir, filename));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ./docs/PULL_REQUEST_TEMPLATE/*.md
|
|
74
|
+
pr_dir = PR_TEMPLATE.DirDocs(repo_root);
|
|
75
|
+
if (await safe_exists(pr_dir)) {
|
|
76
|
+
for (const filename of await fs.readdir(pr_dir)) {
|
|
77
|
+
pr_templates.push(path.join(pr_dir, filename));
|
|
78
|
+
}
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
// check if repo has multiple pr templates
|
|
@@ -71,14 +85,20 @@ async function run() {
|
|
|
71
85
|
|
|
72
86
|
if (pr_templates.length > 0) {
|
|
73
87
|
actions.output(
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
<Ink.Box flexDirection="column">
|
|
89
|
+
{pr_templates.map((filepath) => {
|
|
90
|
+
const relpath = path.relative(repo_root, filepath);
|
|
91
|
+
return <Ink.Text key={filepath}>- {relpath}</Ink.Text>;
|
|
92
|
+
})}
|
|
93
|
+
|
|
94
|
+
<FormatText
|
|
95
|
+
wrapper={<Ink.Text color={colors.yellow} />}
|
|
96
|
+
message="{count} queryable templates found, but not supported."
|
|
97
|
+
values={{
|
|
98
|
+
count: <Ink.Text color={colors.blue}>{pr_templates.length}</Ink.Text>,
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
</Ink.Box>,
|
|
82
102
|
);
|
|
83
103
|
}
|
|
84
104
|
|
|
@@ -91,8 +111,11 @@ const PR_TEMPLATE = Object.freeze({
|
|
|
91
111
|
Github: (root: string) => path.join(root, ".github", "pull_request_template.md"),
|
|
92
112
|
Root: (root: string) => path.join(root, "pull_request_template.md"),
|
|
93
113
|
Docs: (root: string) => path.join(root, "docs", "pull_request_template.md"),
|
|
94
|
-
|
|
114
|
+
|
|
115
|
+
DirDocs: (root: string) => path.join(root, "docs", "PULL_REQUEST_TEMPLATE/"),
|
|
116
|
+
DirGithub: (root: string) => path.join(root, ".github", "PULL_REQUEST_TEMPLATE/"),
|
|
95
117
|
});
|
|
96
118
|
|
|
97
119
|
// prettier-ignore
|
|
98
|
-
|
|
120
|
+
//
|
|
121
|
+
const PR_TEMPLATE_KEY_LIST = ["Github", "Root", "Docs"] satisfies Array<keyof typeof PR_TEMPLATE>;
|
package/src/app/SyncGithub.tsx
CHANGED
|
@@ -240,8 +240,6 @@ async function run() {
|
|
|
240
240
|
if (!is_master_base(group)) {
|
|
241
241
|
// ensure base matches pr in github
|
|
242
242
|
await github.pr_edit({ branch: group.id, base: group.base });
|
|
243
|
-
} else {
|
|
244
|
-
await github.pr_edit({ branch: group.id });
|
|
245
243
|
}
|
|
246
244
|
} else {
|
|
247
245
|
// create pr in github
|
package/src/core/github.tsx
CHANGED
|
@@ -171,6 +171,10 @@ export async function pr_edit(args: EditPullRequestArgs) {
|
|
|
171
171
|
// const actions = state.actions;
|
|
172
172
|
// actions.debug(`github.pr_edit ${JSON.stringify(args)}`);
|
|
173
173
|
|
|
174
|
+
if (!args.base && !args.body) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
174
178
|
const command_parts = [`gh pr edit ${args.branch}`];
|
|
175
179
|
|
|
176
180
|
if (args.base) {
|