Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
fix: use task order rather than version
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackarySantana committed Feb 20, 2024
1 parent c1d95e0 commit 190bbe9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gql/queries/last-mainline-commit.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ query LastMainlineCommit(
tasks {
execution
id
order
status
}
}
id
order
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/pages/task/actionButtons/relevantCommits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,8 +86,7 @@ export const RelevantCommits: React.FC<RelevantCommitsProps> = ({ 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.
Expand Down
10 changes: 8 additions & 2 deletions src/pages/task/actionButtons/relevantCommits/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { BaseVersionAndTaskQuery } from "gql/generated/types";
import {
BaseVersionAndTaskQuery,
LastMainlineCommitQuery,
} from "gql/generated/types";

export enum CommitType {
Base = "base",
Expand All @@ -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];
16 changes: 5 additions & 11 deletions src/pages/task/actionButtons/relevantCommits/utils.ts
Original file line number Diff line number Diff line change
@@ -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 = "#";
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

0 comments on commit 190bbe9

Please sign in to comment.