mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 02:02:42 +00:00
* feat(protocol): add forge check presentation metadata Expose optional rawStatus, isManual, and requiresAction fields while keeping older check payloads backward-compatible. * fix(gitea): model Actions jobs as tasks Gitea's /actions/tasks endpoint returns individual jobs rather than workflow runs. Preserve sibling tasks from the latest execution, avoid collapsing same-name jobs, and enrich blocked tasks with run-level approval metadata. * feat(app): distinguish forge check presentation states * fix(gitlab): preserve pipeline job semantics * refactor(app): centralize forge check presentation policy Use one canonical category order, count shape, visual policy, and translated copy mapping across sidebar, hover-card, PR-pane, and GitLab pipeline surfaces. * refactor: consolidate forge check handling * feat(forge): auto-attach pasted forge references * docs(compat): correct forge rollout metadata * refactor(forge): model check nuances as traits * fix(forge): harden checks from branch review Structural Gitea Actions shadow dedup by run id (verified upstream), rerun grouping without workflow_id, shared trait/status constants and Gitea state mapping in the protocol package, all cloud host aliases in pasted-link matching, logged glab job-detail failures, concurrent approvals/pipeline fetch, checks aggregate from the same pipeline as the job list, and removal of the unread check-level rawStatus. The released pipeline-level rawStatus is staged for removal under COMPAT(pipelineRawStatus). * fix(gitea): detect fork-PR Actions approval hold as action_required gitea.com represents a fork PR awaiting Actions approval as a run in status "waiting" with no tasks and pending shadow commit statuses; it does not expose need_approval. The previous mapping only set action_required from a task with blocked+need_approval, so the gate never surfaced (0 tasks -> early return; need_approval absent). Detect the hold from /actions/runs: a waiting/blocked run whose PR is cross-repo (head.repo.id != base.repo.id), or one that does expose need_approval (self-hosted). Tag the run's pending shadow statuses action_required. Runs are only fetched when a pending shadow has no covering task, keeping the common path at two requests. Verified live against gitea.com fork PR (run 715170, waiting, cross-repo). * fix(gitea): resolve cross-fork PRs by head sha The current-PR matcher gated candidates on the checkout owner (giteaHeadOwner === expectedHeadOwner), which excludes every fork PR: its head carries the fork owner while the checkout is the base repo, so a fork PR - the only shape that can be approval-held on Gitea - never resolved and its checks never showed in-app. GitLab has no such gate (it resolves fork MRs from the target project by source branch). Accept a recent PR whose head sha equals the workspace head sha regardless of owner; the sha is an unambiguous identity, so the anti-collision owner gate still applies when no sha match is available. Verified live against gitea.com fork PR #6 (resolves + renders action_required). * fix: resolve forge rebase drift * fix: type forge auto-attach boundary * fix(i18n): add Korean check status copy --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
261 lines
7.8 KiB
TypeScript
261 lines
7.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildForgeBlobUrl,
|
|
buildForgeBranchTreeUrl,
|
|
buildForgeChecksUrl,
|
|
hasForgeWebUrls,
|
|
} from "./forge-url";
|
|
|
|
describe("buildForgeChecksUrl", () => {
|
|
it.each([
|
|
[
|
|
"github",
|
|
"https://github.com/acme/repo/pull/12",
|
|
"https://github.com/acme/repo/pull/12/checks",
|
|
],
|
|
[
|
|
"gitlab",
|
|
"https://gitlab.com/acme/repo/-/merge_requests/12",
|
|
"https://gitlab.com/acme/repo/-/merge_requests/12/pipelines",
|
|
],
|
|
["codeberg", "https://codeberg.org/acme/repo/pulls/12", null],
|
|
["bitbucket", "https://bitbucket.org/acme/repo/pull-requests/12", null],
|
|
["gitlab", "not a url", null],
|
|
] as const)("maps the %s checks URL", (forge, url, expected) => {
|
|
expect(buildForgeChecksUrl(forge, url)).toBe(expected);
|
|
});
|
|
});
|
|
|
|
describe("buildForgeBranchTreeUrl", () => {
|
|
it("builds a branch-specific GitHub tree URL", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("github", {
|
|
remoteUrl: "git@github.com:acme/repo.git",
|
|
branch: "feature/workspace-button",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/tree/feature/workspace-button");
|
|
});
|
|
|
|
it("encodes reserved branch characters while preserving slash-separated branch names", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "feature/ship #42",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/tree/feature/ship%20%2342");
|
|
});
|
|
|
|
it("uses the GitLab /-/tree/ infix and supports subgroups", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("gitlab", {
|
|
remoteUrl: "https://gitlab.com/group/sub/repo.git",
|
|
branch: "main",
|
|
}),
|
|
).toBe("https://gitlab.com/group/sub/repo/-/tree/main");
|
|
});
|
|
|
|
it("uses the Gitea-family /src/branch/ infix", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("gitea", {
|
|
remoteUrl: "https://gitea.com/acme/repo.git",
|
|
branch: "main",
|
|
}),
|
|
).toBe("https://gitea.com/acme/repo/src/branch/main");
|
|
expect(
|
|
buildForgeBranchTreeUrl("codeberg", {
|
|
remoteUrl: "https://codeberg.org/acme/repo.git",
|
|
branch: "main",
|
|
}),
|
|
).toBe("https://codeberg.org/acme/repo/src/branch/main");
|
|
});
|
|
|
|
it("preserves a non-default port for a self-hosted https remote", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("forgejo", {
|
|
remoteUrl: "https://home-git.example.com:60443/team/repo.git",
|
|
branch: "master",
|
|
}),
|
|
).toBe("https://home-git.example.com:60443/team/repo/src/branch/master");
|
|
});
|
|
|
|
it("omits the port for a self-hosted remote on the default port", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("forgejo", {
|
|
remoteUrl: "https://home-git.example.com/team/repo.git",
|
|
branch: "master",
|
|
}),
|
|
).toBe("https://home-git.example.com/team/repo/src/branch/master");
|
|
});
|
|
|
|
it("returns null when the current branch is unavailable", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "HEAD",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("returns null for a forge with no known URL grammar", () => {
|
|
expect(
|
|
buildForgeBranchTreeUrl("bitbucket", {
|
|
remoteUrl: "https://bitbucket.org/acme/repo.git",
|
|
branch: "main",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("buildForgeBlobUrl", () => {
|
|
it("builds a blob URL for a file path", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "git@github.com:acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/src/index.ts");
|
|
});
|
|
|
|
it("appends a single-line anchor", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
lineStart: 12,
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/src/index.ts#L12");
|
|
});
|
|
|
|
it("appends a GitHub line range anchor (#L12-L20)", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
lineStart: 12,
|
|
lineEnd: 20,
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/src/index.ts#L12-L20");
|
|
});
|
|
|
|
it("uses the GitLab /-/blob/ infix and #L12-20 range anchor", () => {
|
|
expect(
|
|
buildForgeBlobUrl("gitlab", {
|
|
remoteUrl: "https://gitlab.com/group/sub/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
lineStart: 12,
|
|
lineEnd: 20,
|
|
}),
|
|
).toBe("https://gitlab.com/group/sub/repo/-/blob/main/src/index.ts#L12-20");
|
|
});
|
|
|
|
it("uses the Gitea-family /src/branch/ blob path with a #L12-L20 anchor", () => {
|
|
expect(
|
|
buildForgeBlobUrl("forgejo", {
|
|
remoteUrl: "https://codeberg.org/acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
lineStart: 12,
|
|
lineEnd: 20,
|
|
}),
|
|
).toBe("https://codeberg.org/acme/repo/src/branch/main/src/index.ts#L12-L20");
|
|
});
|
|
|
|
it("derives the web host from a self-hosted remote (GitHub Enterprise)", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "git@github.acme.internal:team/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
}),
|
|
).toBe("https://github.acme.internal/team/repo/blob/main/src/index.ts");
|
|
});
|
|
|
|
it("preserves a non-default port for a self-hosted https remote", () => {
|
|
expect(
|
|
buildForgeBlobUrl("forgejo", {
|
|
remoteUrl: "https://home-git.example.com:60443/team/repo.git",
|
|
branch: "master",
|
|
path: "src/index.ts",
|
|
lineStart: 12,
|
|
lineEnd: 20,
|
|
}),
|
|
).toBe("https://home-git.example.com:60443/team/repo/src/branch/master/src/index.ts#L12-L20");
|
|
});
|
|
|
|
it("canonicalizes the github.com SSH-alias host to the web host", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "ssh://git@ssh.github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/src/index.ts");
|
|
});
|
|
|
|
it("strips leading slashes and encodes path segments", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "/src/a b/c#d.ts",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/src/a%20b/c%23d.ts");
|
|
});
|
|
|
|
it("normalizes harmless dot segments in the blob path", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "./src/../index.ts",
|
|
}),
|
|
).toBe("https://github.com/acme/repo/blob/main/index.ts");
|
|
});
|
|
|
|
it("returns null for blob paths that escape above the repo root", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "../outside.ts",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("returns null when the path is missing", () => {
|
|
expect(
|
|
buildForgeBlobUrl("github", {
|
|
remoteUrl: "https://github.com/acme/repo.git",
|
|
branch: "main",
|
|
path: "",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("returns null for a forge with no known URL grammar", () => {
|
|
expect(
|
|
buildForgeBlobUrl("bitbucket", {
|
|
remoteUrl: "https://bitbucket.org/acme/repo.git",
|
|
branch: "main",
|
|
path: "src/index.ts",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("hasForgeWebUrls", () => {
|
|
it("is true for forges with a known URL grammar", () => {
|
|
for (const forge of ["github", "gitlab", "gitea", "forgejo", "codeberg"]) {
|
|
expect(hasForgeWebUrls(forge)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("is false for an unknown forge", () => {
|
|
expect(hasForgeWebUrls("bitbucket")).toBe(false);
|
|
});
|
|
});
|