Skip to content

Commit

Permalink
link <1.21.4 github urls to archive repo
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer authored and MiniDigger committed Dec 30, 2024
1 parent 5f7682e commit cc46d69
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/data/SoftwareBuildChanges.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import type { ReactElement } from "react";
import { Fragment } from "react";

import { getProjectRepository } from "@/lib/service/github";
import type { Build } from "@/lib/service/types";
import styles from "@/styles/components/data/SoftwareBuildChanges.module.css";

export interface SoftwareBuildChangesProps {
project: string;
build: Build;
version: string;
}

const SoftwareBuildChanges = ({
project,
build,
version,
}: SoftwareBuildChangesProps): ReactElement => (
<>
{build.changes.map((change) => (
<p key={change.commit}>
<a
href={`https://github.com/PaperMC/${project}/commit/${change.commit}`}
href={`${getProjectRepository(project, version)}/commit/${change.commit}`}
className={styles.commit}
rel="noreferrer"
target="_blank"
Expand Down
6 changes: 5 additions & 1 deletion src/components/data/SoftwareBuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ const SoftwareBuilds = ({
<DownloadIcon className="w-4 h-4" />#{build.build}
</a>
<div className="flex-1 flex flex-col text-gray-900 dark:text-gray-200">
<SoftwareBuildChanges project={project} build={build} />
<SoftwareBuildChanges
project={project}
build={build}
version={version}
/>
</div>
<div
className="hidden md:block text-gray-500 dark:text-gray-300 mt-1 ml-2"
Expand Down
6 changes: 5 additions & 1 deletion src/components/data/SoftwareBuildsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ const SoftwareBuildsTable = ({
</span>
</td>
<td>
<SoftwareBuildChanges project={project} build={build} />
<SoftwareBuildChanges
project={project}
build={build}
version={version}
/>
</td>
<td
className={"whitespace-nowrap"}
Expand Down
18 changes: 18 additions & 0 deletions src/lib/service/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ const getURL = (pageIndex: number, previousPageData: any): string | null => {

export const useGitHubContributors = (): SWRInfiniteResponse<Contributor[]> =>
useSWRInfinite(getURL, fetcher, swrNoAutoUpdateSettings);

export const getProjectRepository = (
project: string,
version: string,
): string => {
if (project !== "paper") return `https://github.com/PaperMC/${project}`;

const baseVersion = [21, 4]; // 1.21.4 is after the hardfork
const isBelowBaseVersion = version
.replace(/^1\./, "")
.split(".")
.map(Number)
.some((v, i) => v < (baseVersion[i] || 0));

return isBelowBaseVersion
? "https://github.com/PaperMC/Paper-Archive"
: "https://github.com/PaperMC/Paper";
};

0 comments on commit cc46d69

Please sign in to comment.