Move action url generation to shared function
This commit is contained in:
@@ -65,3 +65,10 @@ export function actionIdentifier(ref: ActionReference): string {
|
|||||||
}
|
}
|
||||||
return `${ref.owner}/${ref.name}/${ref.ref}`;
|
return `${ref.owner}/${ref.name}/${ref.ref}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function actionUrl(actionRef: ActionReference): string {
|
||||||
|
// TODO: Support base uri for GHES
|
||||||
|
const gitHubBaseUri = "https://www.github.com/";
|
||||||
|
|
||||||
|
return `${gitHubBaseUri}${actionRef.owner}/${actionRef.name}/tree/${actionRef.ref}/${actionRef.path || ""}`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {isJob} from "@github/actions-workflow-parser/model/type-guards";
|
|||||||
import {File} from "@github/actions-workflow-parser/workflows/file";
|
import {File} from "@github/actions-workflow-parser/workflows/file";
|
||||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||||
import {DocumentLink} from "vscode-languageserver-types";
|
import {DocumentLink} from "vscode-languageserver-types";
|
||||||
import {parseActionReference} from "./action";
|
import {actionUrl, parseActionReference} from "./action";
|
||||||
import {nullTrace} from "./nulltrace";
|
import {nullTrace} from "./nulltrace";
|
||||||
import {mapRange} from "./utils/range";
|
import {mapRange} from "./utils/range";
|
||||||
|
|
||||||
@@ -26,9 +26,6 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
|
|||||||
// Add links to referenced actions
|
// Add links to referenced actions
|
||||||
const actionLinks: DocumentLink[] = [];
|
const actionLinks: DocumentLink[] = [];
|
||||||
|
|
||||||
// TODO: Support base uri for GHES
|
|
||||||
const gitHubBaseUri = "https://www.github.com/";
|
|
||||||
|
|
||||||
for (const job of template?.jobs || []) {
|
for (const job of template?.jobs || []) {
|
||||||
if (!job || !isJob(job)) {
|
if (!job || !isJob(job)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -40,9 +37,7 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${gitHubBaseUri}${actionRef.owner}/${actionRef.name}/tree/${actionRef.ref}/${
|
const url = actionUrl(actionRef);
|
||||||
actionRef.path || ""
|
|
||||||
}`;
|
|
||||||
|
|
||||||
actionLinks.push({
|
actionLinks.push({
|
||||||
range: mapRange(step.uses.range),
|
range: mapRange(step.uses.range),
|
||||||
|
|||||||
Reference in New Issue
Block a user