Skip to content

Commit d11e915

Browse files
committed
Resolve issues discovered by copilot.
1 parent f4007f0 commit d11e915

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

server/fishtest/static/js/application.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,12 @@ function remainingApiCalls(response) {
654654
// URL.parse is too recent to use
655655

656656
function parseRepo(url) {
657+
// First check that this is a github repo
658+
const re =
659+
/^https:\/\/(www\.)?github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/?$/;
660+
if (!url.match(re)) {
661+
throw new Error(`The url ${url} is not a GitHub repo`);
662+
}
657663
const chunks = url.split("/");
658664
const user = chunks[3];
659665
const repo = chunks[4];

server/fishtest/static/js/pull_request.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class PullRequest {
259259
if (!run.args.sprt.state) {
260260
throw new Error("Pull requests can only contain finished tests");
261261
}
262-
if (run.args.new_tc && !run.args.tc != !run.args.new_tc) {
262+
if (run.args.new_tc && run.args.tc != run.args.new_tc) {
263263
throw new Error("Pull requests cannot contain time odds tests");
264264
}
265265
this.runIdCache[runId] = run;
@@ -299,7 +299,7 @@ class PullRequest {
299299
}
300300
branch = run.args.new_tag;
301301
tests_repo = run.args.tests_repo;
302-
latest = runs.start_time;
302+
latest = run.start_time;
303303
}
304304
}
305305
let user, repo;
@@ -410,11 +410,7 @@ class PullRequest {
410410
};
411411
let body = await this.renderBody(token);
412412
body = body.replaceAll("<br>", "\n");
413-
if (this.title) {
414-
options.title = escapeHtml(this.title);
415-
} else {
416-
options.title = await this.renderTitle(token);
417-
}
413+
options.title = await this.renderTitle(token);
418414
options.body = body;
419415
// TODO Incorporate user
420416
if (this.numberCache[userData.branch]) {

server/fishtest/templates/pull_request.mak

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@
6868
submitBtn.textContent="Submit";
6969
}
7070
} catch(e) {
71-
console.log(e);
71+
const text = await processError(e);
72+
alertError(text);
73+
console.error(text);
7274
}
7375
previewTab.addEventListener("click", async () => {
7476
PR.title = titleElt.value;

0 commit comments

Comments
 (0)