git-stack-cli
Advanced tools
| import { test, expect } from "bun:test"; | ||
| import * as GatherMetadata from "~/app/GatherMetadata"; | ||
| test("invalid origin", () => { | ||
| const origin_url = ""; | ||
| const repo_path = GatherMetadata.get_repo_path(origin_url); | ||
| expect(repo_path).toBe(null); | ||
| }); | ||
| test("https .git", () => { | ||
| const origin_url = "https://github.com/magus/git-multi-diff-playground.git"; | ||
| const repo_path = GatherMetadata.get_repo_path(origin_url); | ||
| expect(repo_path).toBe("magus/git-multi-diff-playground"); | ||
| }); | ||
| test("https without .git", () => { | ||
| const origin_url = "https://github.com/magus/git-multi-diff-playground"; | ||
| const repo_path = GatherMetadata.get_repo_path(origin_url); | ||
| expect(repo_path).toBe("magus/git-multi-diff-playground"); | ||
| }); | ||
| test("git@ .git", () => { | ||
| const origin_url = "git@github.com:magus/git-multi-diff-playground.git"; | ||
| const repo_path = GatherMetadata.get_repo_path(origin_url); | ||
| expect(repo_path).toBe("magus/git-multi-diff-playground"); | ||
| }); | ||
| test("git@ without .git", () => { | ||
| const origin_url = "git@github.com:magus/git-multi-diff-playground"; | ||
| const repo_path = GatherMetadata.get_repo_path(origin_url); | ||
| expect(repo_path).toBe("magus/git-multi-diff-playground"); | ||
| }); |
+1
-1
| { | ||
| "name": "git-stack-cli", | ||
| "version": "2.8.1", | ||
| "version": "2.8.2", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "author": "magus", |
+6
-0
@@ -70,2 +70,8 @@ <p align="center"> | ||
| ### Base PRs on `master` branch | ||
| By default PRs are stacked based on the order of commits in your branch. | ||
| To separate a PR and base it on your `master` branch press `m`. | ||
| ### Editing existing commits and pull requests | ||
@@ -72,0 +78,0 @@ |
@@ -100,6 +100,17 @@ import * as React from "react"; | ||
| export function get_repo_path(origin_url: string): null | string { | ||
| try { | ||
| return match_group(origin_url, RE.repo_path, "repo_path"); | ||
| } catch { | ||
| // pass | ||
| } | ||
| return null; | ||
| } | ||
| const RE = { | ||
| // git@github.com:magus/git-multi-diff-playground.git | ||
| // https://github.com/magus/git-multi-diff-playground.git | ||
| repo_path: /(?<repo_path>[^:^/]+\/[^/]+)\.git/, | ||
| // the .git suffix is optional for remote urls, and may not always be provided | ||
| // https://regex101.com/r/pICG7G/1 | ||
| repo_path: /(?<repo_path>[^:^/]+\/[^/]+?)(\.git)?$/, | ||
| }; | ||
@@ -106,0 +117,0 @@ |
@@ -42,6 +42,7 @@ import * as React from "react"; | ||
| for (const key of PR_TEMPLATE_KEY_LIST) { | ||
| const pr_template_fn = PR_TEMPLATE[key as keyof typeof PR_TEMPLATE]; | ||
| const pr_template_fn = PR_TEMPLATE[key]; | ||
| const pr_template_file = pr_template_fn(repo_root); | ||
| if (await safe_exists(pr_template_fn(repo_root))) { | ||
| pr_template_body = await fs.readFile(pr_template_fn(repo_root), "utf-8"); | ||
| if (await safe_exists(pr_template_file)) { | ||
| pr_template_body = await fs.readFile(pr_template_file, "utf-8"); | ||
@@ -62,8 +63,21 @@ actions.output( | ||
| let pr_templates: Array<string> = []; | ||
| let pr_dir: string = ""; | ||
| // ./.github/PULL_REQUEST_TEMPLATE/*.md | ||
| let pr_templates: Array<string> = []; | ||
| if (await safe_exists(PR_TEMPLATE.TemplateDir(repo_root))) { | ||
| pr_templates = await fs.readdir(PR_TEMPLATE.TemplateDir(repo_root)); | ||
| pr_dir = PR_TEMPLATE.DirGithub(repo_root); | ||
| if (await safe_exists(pr_dir)) { | ||
| for (const filename of await fs.readdir(pr_dir)) { | ||
| pr_templates.push(path.join(pr_dir, filename)); | ||
| } | ||
| } | ||
| // ./docs/PULL_REQUEST_TEMPLATE/*.md | ||
| pr_dir = PR_TEMPLATE.DirDocs(repo_root); | ||
| if (await safe_exists(pr_dir)) { | ||
| for (const filename of await fs.readdir(pr_dir)) { | ||
| pr_templates.push(path.join(pr_dir, filename)); | ||
| } | ||
| } | ||
| // check if repo has multiple pr templates | ||
@@ -76,10 +90,16 @@ actions.set((state) => { | ||
| actions.output( | ||
| <FormatText | ||
| wrapper={<Ink.Text color={colors.yellow} />} | ||
| message="{count} queryable templates found under {dir}, but not supported." | ||
| values={{ | ||
| count: <Ink.Text color={colors.blue}>{pr_templates.length}</Ink.Text>, | ||
| dir: <Brackets>{PR_TEMPLATE.TemplateDir("")}</Brackets>, | ||
| }} | ||
| />, | ||
| <Ink.Box flexDirection="column"> | ||
| {pr_templates.map((filepath) => { | ||
| const relpath = path.relative(repo_root, filepath); | ||
| return <Ink.Text key={filepath}>- {relpath}</Ink.Text>; | ||
| })} | ||
| <FormatText | ||
| wrapper={<Ink.Text color={colors.yellow} />} | ||
| message="{count} queryable templates found, but not supported." | ||
| values={{ | ||
| count: <Ink.Text color={colors.blue}>{pr_templates.length}</Ink.Text>, | ||
| }} | ||
| /> | ||
| </Ink.Box>, | ||
| ); | ||
@@ -97,6 +117,9 @@ } | ||
| Docs: (root: string) => path.join(root, "docs", "pull_request_template.md"), | ||
| TemplateDir: (root: string) => path.join(root, ".github", "PULL_REQUEST_TEMPLATE"), | ||
| DirDocs: (root: string) => path.join(root, "docs", "PULL_REQUEST_TEMPLATE/"), | ||
| DirGithub: (root: string) => path.join(root, ".github", "PULL_REQUEST_TEMPLATE/"), | ||
| }); | ||
| // prettier-ignore | ||
| const PR_TEMPLATE_KEY_LIST = Object.keys(PR_TEMPLATE) as Array<keyof typeof PR_TEMPLATE>; | ||
| // | ||
| const PR_TEMPLATE_KEY_LIST = ["Github", "Root", "Docs"] satisfies Array<keyof typeof PR_TEMPLATE>; |
@@ -243,4 +243,2 @@ import * as React from "react"; | ||
| await github.pr_edit({ branch: group.id, base: group.base }); | ||
| } else { | ||
| await github.pr_edit({ branch: group.id }); | ||
| } | ||
@@ -247,0 +245,0 @@ } else { |
@@ -174,2 +174,6 @@ import * as React from "react"; | ||
| if (!args.base && !args.body) { | ||
| return; | ||
| } | ||
| const command_parts = [`gh pr edit ${args.branch}`]; | ||
@@ -176,0 +180,0 @@ |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
4893628
0.09%112
0.9%9698
0.59%190
3.26%