Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link <1.21.4 github urls to archive repo #124

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
};