Watch
0
0
Fork
You've already forked hyperhive
0

review try-out: test the branch push request; name the open-PR gating

push_classifier_branch's request moves into push_branch, which takes the
forge client, so a test can run it against a stand-in forge. The tests
pin the POST to /repos/o/r/contents and its body: base and new branch,
no force overwrite, the message, the operator as author with the
service account as committer, the base64 content, and update with the
blob sha or create without one.

The page's open-a-PR gating becomes rowsProblem in TryOutTypes.ts,
beside the other form checks. swarm-ui has no test runner, so the
typecheck is the only check on it.

Refs #5259
This commit is contained in:
atlas 2026-10-14 16:13:57 +02:00 • committed by mara
commit 915364c918
3 changed files with 140 additions and 48 deletions

View file

@ -37,11 +37,10 @@ import { ClassificationEditor } from "./ClassificationEditor.js";
import { TryOutResult } from "./TryOutResult.js";
import {
draftFromRule,
draftProblem,
duplicateName,
hasTypedText,
prNumber,
repoProblem,
rowsProblem,
toBody,
type ClassificationDraft,
type OpenPrAnswer,
@ -218,15 +217,10 @@ export function ReviewTryOutPage() {
};
}, [runId]);
// What keeps the rows from going to the repo; a PR number is not needed.
const rowsProblem =
repoProblem(repo) ??
drafts.map(draftProblem).find((p) => p !== null) ??
duplicateName(drafts) ??
null;
const openPrProblem = rowsProblem(repo, drafts);
const problem =
(prNumber(pr) === null ? "a PR number is a whole number above 0" : null) ??
rowsProblem;
openPrProblem;
async function run(e: Event) {
e.preventDefault();
@ -410,7 +404,7 @@ export function ReviewTryOutPage() {
</Button>
<Button
onClick={() => void openPr()}
disabled={opening || rowsProblem !== null}
disabled={opening || openPrProblem !== null}
>
{opening ? "pushing…" : "open a PR"}
</Button>

View file

@ -150,6 +150,20 @@ export function duplicateName(drafts: ClassificationDraft[]): string | null {
return null;
}
/** What keeps the rows from going to the repo as a PR, or null: the repo, then
* each row, then a shared name. Unlike a run, it needs no PR number. */
export function rowsProblem(
repo: string,
drafts: ClassificationDraft[],
): string | null {
return (
repoProblem(repo) ??
drafts.map(draftProblem).find((p) => p !== null) ??
duplicateName(drafts) ??
null
);
}
export function toBody(d: ClassificationDraft): ClassificationBody {
return {
name: d.name.trim(),