diff --git a/src/gql/generated/types.ts b/src/gql/generated/types.ts index e9555b70e3..0012cbbb9f 100644 --- a/src/gql/generated/types.ts +++ b/src/gql/generated/types.ts @@ -6165,13 +6165,13 @@ export type LastMainlineCommitQuery = { version?: { __typename?: "Version"; id: string; - order: number; buildVariants?: Array<{ __typename?: "GroupedBuildVariant"; tasks?: Array<{ __typename?: "Task"; execution: number; id: string; + order: number; status: string; } | null> | null; } | null> | null; diff --git a/src/gql/queries/last-mainline-commit.graphql b/src/gql/queries/last-mainline-commit.graphql index 30c11b38ba..098e78d78f 100644 --- a/src/gql/queries/last-mainline-commit.graphql +++ b/src/gql/queries/last-mainline-commit.graphql @@ -18,11 +18,11 @@ query LastMainlineCommit( tasks { execution id + order status } } id - order } } } diff --git a/src/pages/task/actionButtons/relevantCommits/index.tsx b/src/pages/task/actionButtons/relevantCommits/index.tsx index c54fde1f38..5e2404a786 100644 --- a/src/pages/task/actionButtons/relevantCommits/index.tsx +++ b/src/pages/task/actionButtons/relevantCommits/index.tsx @@ -18,11 +18,7 @@ import { BASE_VERSION_AND_TASK, LAST_MAINLINE_COMMIT } from "gql/queries"; import { TaskStatus } from "types/task"; import { statuses, string } from "utils"; import { CommitType } from "./types"; -import { - getLinks, - getOrderFromMainlineCommitsQuery, - getTaskFromMainlineCommitsQuery, -} from "./utils"; +import { getLinks, getTaskFromMainlineCommitsQuery } from "./utils"; const { applyStrictRegex } = string; const { isFinishedTaskStatus } = statuses; @@ -90,8 +86,7 @@ export const RelevantCommits: React.FC = ({ taskId }) => { }, }); const lastPassingTask = getTaskFromMainlineCommitsQuery(lastPassingTaskData); - const passingOrderNumber = - getOrderFromMainlineCommitsQuery(lastPassingTaskData); + const passingOrderNumber = lastPassingTask?.order; // The breaking commit is the first failing commit after the last passing commit. // The skip order number should be the last passing commit's order number + 1. diff --git a/src/pages/task/actionButtons/relevantCommits/types.ts b/src/pages/task/actionButtons/relevantCommits/types.ts index 3879cc369b..15e5cce2a5 100644 --- a/src/pages/task/actionButtons/relevantCommits/types.ts +++ b/src/pages/task/actionButtons/relevantCommits/types.ts @@ -1,4 +1,7 @@ -import { BaseVersionAndTaskQuery } from "gql/generated/types"; +import { + BaseVersionAndTaskQuery, + LastMainlineCommitQuery, +} from "gql/generated/types"; export enum CommitType { Base = "base", @@ -7,4 +10,7 @@ export enum CommitType { LastExecuted = "lastExecuted", } -export type CommitTask = BaseVersionAndTaskQuery["task"]["baseTask"]; +export type BaseTask = BaseVersionAndTaskQuery["task"]["baseTask"]; + +export type CommitTask = + LastMainlineCommitQuery["mainlineCommits"]["versions"][number]["version"]["buildVariants"][number]["tasks"][number]; diff --git a/src/pages/task/actionButtons/relevantCommits/utils.ts b/src/pages/task/actionButtons/relevantCommits/utils.ts index bc504afe4c..a18f0770c3 100644 --- a/src/pages/task/actionButtons/relevantCommits/utils.ts +++ b/src/pages/task/actionButtons/relevantCommits/utils.ts @@ -1,7 +1,7 @@ import { getTaskRoute } from "constants/routes"; import { LastMainlineCommitQuery } from "gql/generated/types"; import { reportError } from "utils/errorReporting"; -import { CommitTask, CommitType } from "./types"; +import { BaseTask, CommitTask, CommitType } from "./types"; // a link cannot be null, so it's common to use # as a substitute. const nullLink = "#"; @@ -12,10 +12,10 @@ export const getLinks = ({ lastPassingTask, parentTask, }: { - breakingTask: CommitTask; - lastExecutedTask: CommitTask; - lastPassingTask: CommitTask; - parentTask: CommitTask; + breakingTask: BaseTask; + lastExecutedTask: BaseTask; + lastPassingTask: BaseTask; + parentTask: BaseTask; }) => { if (!parentTask) { return { @@ -60,9 +60,3 @@ export const getTaskFromMainlineCommitsQuery = ( } return buildVariants[0]?.tasks[0]; }; - -export const getOrderFromMainlineCommitsQuery = ( - data: LastMainlineCommitQuery, -): number => - data?.mainlineCommits.versions.find(({ version }) => version)?.version - .order ?? -1;