@ravshansbox/pi-next-issue 1.0.14 → 1.1.0
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 +1 -1
- package/package.json +1 -1
- package/src/git.ts +12 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A [pi](https://github.com/earendil-works/pi) extension that works through the op
|
|
|
6
6
|
pi install npm:@ravshansbox/pi-next-issue
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
It needs `git` and an authenticated [`gh`](https://cli.github.com/).
|
|
9
|
+
It needs `git` and an authenticated [`gh`](https://cli.github.com/). It works with github.com and GitHub Enterprise remotes.
|
|
10
10
|
|
|
11
11
|
## Use
|
|
12
12
|
|
package/package.json
CHANGED
package/src/git.ts
CHANGED
|
@@ -9,11 +9,20 @@ export async function repoRoot(cwd: string): Promise<string> {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function parseRemote(url: string): string {
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const remote = url.trim();
|
|
13
|
+
const hosted =
|
|
14
|
+
/^(?:[\w+.-]+:\/\/)?(?:[^@/]+@)?([^/:]+)(?::\d+)?[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(
|
|
15
|
+
remote,
|
|
16
|
+
);
|
|
17
|
+
if (hosted !== null) {
|
|
18
|
+
const [, host, owner, name] = hosted;
|
|
19
|
+
return host?.toLowerCase() === 'github.com' ? `${owner}/${name}` : `${host}/${owner}/${name}`;
|
|
20
|
+
}
|
|
21
|
+
const path = /[/:]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/.exec(remote);
|
|
22
|
+
if (path === null) {
|
|
14
23
|
throw new Error(`cannot read the owner and name from the git remote ${url}`);
|
|
15
24
|
}
|
|
16
|
-
return `${
|
|
25
|
+
return `${path[1]}/${path[2]}`;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
export async function remoteSlug(root: string, remote: string): Promise<string> {
|