Skip to content

Commit

Permalink
fix: Fix routing for invalid PR (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
minghay authored Dec 11, 2024
1 parent 88f92f3 commit 725f299
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions app/v2/pipeline/pulls/show/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,37 @@ export default class V2PipelinePullsShowRoute extends Route {
latestEvent = event;
} else {
const newestPrNum = newestPrNumber(prNums);
const baseUrl = `/pipelines/${pipelineId}/events?prNum=${newestPrNum}`;
const url = sha ? `${baseUrl}&sha=${sha}` : baseUrl;

latestEvent = await this.shuttle.fetchFromApi('get', url).then(events => {
return events[0];
});
if (newestPrNum) {
const baseUrl = `/pipelines/${pipelineId}/events?prNum=${newestPrNum}`;
const url = sha ? `${baseUrl}&sha=${sha}` : baseUrl;

latestEvent = await this.shuttle
.fetchFromApi('get', url)
.then(events => {
return events[0];
});
}
}

let jobs = [];

if (event && !pipeline.chainPR) {
jobs = await this.shuttle.fetchFromApi(
'get',
`/pipelines/${pipelineId}/jobs?type=pipeline`
);
if (event) {
this.selectedPrSha.setSha(event.sha);

model.pullRequestJobs.forEach(prJob => {
if (getPrNumber(prJob) === prNum) {
jobs.push({ ...prJob, group: prNum });
}
});
}
if (!pipeline.chainPR) {
jobs = await this.shuttle.fetchFromApi(
'get',
`/pipelines/${pipelineId}/jobs?type=pipeline`
);

this.selectedPrSha.setSha(event.sha);
model.pullRequestJobs.forEach(prJob => {
if (getPrNumber(prJob) === prNum) {
jobs.push({ ...prJob, group: prNum });
}
});
}
}

return {
...model,
Expand Down

0 comments on commit 725f299

Please sign in to comment.