File tree 4 files changed +21
-31
lines changed
4 files changed +21
-31
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,12 @@ export async function getCommitURL(
11
11
commitish : string ,
12
12
options : Options = { } ,
13
13
) : Promise < URL > {
14
- if ( ! options . remote ) {
15
- const remote = await getRemoteContains ( commitish , options ) ;
16
- return getCommitURL ( commitish , { ...options , remote : remote ?? "origin" } ) ;
17
- }
18
- const fetchURL = await getRemoteFetchURL ( options . remote , options ) ;
14
+ const remote = options . remote ??
15
+ await getRemoteContains ( commitish , options ) ??
16
+ "origin" ;
17
+ const fetchURL = await getRemoteFetchURL ( remote , options ) ;
19
18
if ( ! fetchURL ) {
20
- throw new Error ( `Remote '${ options . remote } ' has no fetch URL ` ) ;
19
+ throw new Error ( `No remote '${ remote } ' found ` ) ;
21
20
}
22
21
const hostingService = await getHostingService ( fetchURL , options ) ;
23
22
return hostingService . getCommitURL ( fetchURL , commitish ) ;
Original file line number Diff line number Diff line change @@ -10,13 +10,12 @@ export type Options = ExecuteOptions & {
10
10
export async function getHomeURL (
11
11
options : Options = { } ,
12
12
) : Promise < URL > {
13
- if ( ! options . remote ) {
14
- const remote = await getRemoteContains ( "HEAD" , options ) ;
15
- return getHomeURL ( { ...options , remote : remote ?? "origin" } ) ;
16
- }
17
- const fetchURL = await getRemoteFetchURL ( options . remote , options ) ;
13
+ const remote = options . remote ??
14
+ await getRemoteContains ( "HEAD" , options ) ??
15
+ "origin" ;
16
+ const fetchURL = await getRemoteFetchURL ( remote , options ) ;
18
17
if ( ! fetchURL ) {
19
- throw new Error ( `Remote '${ options . remote } ' has no fetch URL` ) ;
18
+ throw new Error ( `No remote '${ remote } ' found or failed to get fetch URL. ` ) ;
20
19
}
21
20
const hostingService = await getHostingService ( fetchURL , options ) ;
22
21
return hostingService . getHomeURL ( fetchURL ) ;
Original file line number Diff line number Diff line change @@ -13,16 +13,12 @@ export async function getObjectURL(
13
13
path : string ,
14
14
options : Options = { } ,
15
15
) : Promise < URL > {
16
- if ( ! options . remote ) {
17
- const remote = await getRemoteContains ( commitish , options ) ;
18
- return getObjectURL ( commitish , path , {
19
- ...options ,
20
- remote : remote ?? "origin" ,
21
- } ) ;
22
- }
23
- const fetchURL = await getRemoteFetchURL ( options . remote , options ) ;
16
+ const remote = options . remote ??
17
+ await getRemoteContains ( commitish , options ) ??
18
+ "origin" ;
19
+ const fetchURL = await getRemoteFetchURL ( remote , options ) ;
24
20
if ( ! fetchURL ) {
25
- throw new Error ( `Remote '${ options . remote } ' has no fetch URL ` ) ;
21
+ throw new Error ( `No remote '${ remote } ' found ` ) ;
26
22
}
27
23
const hostingService = await getHostingService ( fetchURL , options ) ;
28
24
const [ normPath , range ] = parsePath ( path ) ;
Original file line number Diff line number Diff line change @@ -16,16 +16,12 @@ export async function getPullRequestURL(
16
16
commitish : string ,
17
17
options : Options = { } ,
18
18
) : Promise < URL > {
19
- if ( ! options . remote ) {
20
- const remote = await getRemoteContains ( commitish , options ) ;
21
- return getPullRequestURL ( commitish , {
22
- ...options ,
23
- remote : remote ?? "origin" ,
24
- } ) ;
25
- }
26
- const fetchURL = await getRemoteFetchURL ( options . remote , options ) ;
19
+ const remote = options . remote ??
20
+ await getRemoteContains ( commitish , options ) ??
21
+ "origin" ;
22
+ const fetchURL = await getRemoteFetchURL ( remote , options ) ;
27
23
if ( ! fetchURL ) {
28
- throw new Error ( `Remote '${ options . remote } ' has no fetch URL ` ) ;
24
+ throw new Error ( `No remote '${ remote } ' found ` ) ;
29
25
}
30
26
const hostingService = await getHostingService ( fetchURL , options ) ;
31
27
if ( ! hostingService . getPullRequestURL ) {
@@ -35,7 +31,7 @@ export async function getPullRequestURL(
35
31
}
36
32
const pr = await getPullRequestContains (
37
33
commitish ,
38
- options . remote ,
34
+ remote ,
39
35
options ,
40
36
) ;
41
37
if ( ! pr ) {
You can’t perform that action at this time.
0 commit comments