Move action url generation to shared function

This commit is contained in:
Christopher Schleiden
2023-03-06 14:52:26 -05:00
committed by Josh Gross
parent 6dde0b554d
commit b516b65d3e
2 changed files with 9 additions and 7 deletions
+7
View File
@@ -65,3 +65,10 @@ export function actionIdentifier(ref: ActionReference): string {
}
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 || ""}`;
}
+2 -7
View File
@@ -4,7 +4,7 @@ import {isJob} from "@github/actions-workflow-parser/model/type-guards";
import {File} from "@github/actions-workflow-parser/workflows/file";
import {TextDocument} from "vscode-languageserver-textdocument";
import {DocumentLink} from "vscode-languageserver-types";
import {parseActionReference} from "./action";
import {actionUrl, parseActionReference} from "./action";
import {nullTrace} from "./nulltrace";
import {mapRange} from "./utils/range";
@@ -26,9 +26,6 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
// Add links to referenced actions
const actionLinks: DocumentLink[] = [];
// TODO: Support base uri for GHES
const gitHubBaseUri = "https://www.github.com/";
for (const job of template?.jobs || []) {
if (!job || !isJob(job)) {
continue;
@@ -40,9 +37,7 @@ export async function documentLinks(document: TextDocument): Promise<DocumentLin
continue;
}
const url = `${gitHubBaseUri}${actionRef.owner}/${actionRef.name}/tree/${actionRef.ref}/${
actionRef.path || ""
}`;
const url = actionUrl(actionRef);
actionLinks.push({
range: mapRange(step.uses.range),