CodeBrowserUrl
Builds provider-correct GitHub/GitLab source URLs from a local file + optional line number, given a code-browser configuration that pins the remote base URL, the git root, and the commit SHA to link against.
Extracted into a shared helper so the multiple call sites (com.stigway.engine.commands.analyzefunctiondescriptions.AnalyzeFunctionDescriptionsCommand, com.stigway.engine.commands.analyzefunctionmetrics.AnalyzeFunctionMetricsCommand, and the upcoming Gradle-side getSourceUrl callers) build links the same way.
Types
Pin for one repository: a local git root, the remote base URL (without trailing slash; we trim defensively), and the commit SHA to resolve blob/… against.
Functions
Builds the provider-correct page for Context.commit.
Builds the provider-correct commit page used by build provenance.
Builds an editable source URL only when Context.editRef is available.
Builds an IntelliJ IDEA navigation URI for a repository-owned source file. IDEA matches Context.baseUrl against open/recent projects and resolves the repository-relative path locally; no workstation path is published.
Builds the configured repository location, pinned to Context.commit when it maps to a subdirectory.
Builds the repository URL represented by baseUrl and remotePath. A repository root is linked directly; a configured subdirectory is linked at the same immutable ref used by source links.
Builds a source URL when the repository-relative path is already known.
Returns the <baseUrl>/blob/<commit>/<encoded-path>[#L<line>] URL for a local file, or null if the file isn't inside the git root (no link makes sense outside the tracked tree).
Builds one Context per repo from index-aligned root / remote-URL / commit lists (the shape the Gradle tasks carry from repoLocations.dokkaRepoInfos). Entries with a blank root, URL or commit are dropped — they can't form a link.
URL-encode each /-separated path segment independently and rejoin. Spaces become %20 (not +); other special chars follow URLEncoder.encode(…, UTF-8).
Multi-repo resolution shared by every source-link producer (the diagram enrichment, the function-metrics report, the descriptions report) so a file resolves to the same link everywhere. Two strategies, in order: