Skip to content

Commit ee23beb

Browse files
chore: rename variable, slightly improve error debugging for empty tag name
This error is still crazily mysterious
1 parent 6b102a1 commit ee23beb

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

src/lib/server/github-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,4 +893,4 @@ export class GitHubCache {
893893
}
894894
}
895895

896-
export const gitHubCache = new GitHubCache(KV_REST_API_URL, KV_REST_API_TOKEN, GITHUB_TOKEN);
896+
export const githubCache = new GitHubCache(KV_REST_API_URL, KV_REST_API_TOKEN, GITHUB_TOKEN);

src/lib/server/package-discoverer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Repository, publicRepos } from "$lib/repositories";
22
import type { Prettify } from "$lib/types";
3-
import { GitHubCache, gitHubCache } from "./github-cache";
3+
import { GitHubCache, githubCache } from "./github-cache";
44

55
type Package = {
66
name: string;
@@ -154,4 +154,4 @@ export class PackageDiscoverer {
154154
}
155155
}
156156

157-
export const discoverer = new PackageDiscoverer(gitHubCache, publicRepos);
157+
export const discoverer = new PackageDiscoverer(githubCache, publicRepos);

src/routes/[pid=pid]/[org]/[repo]/[id=number]/+page.server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { error, redirect } from "@sveltejs/kit";
2-
import { gitHubCache } from "$lib/server/github-cache";
2+
import { githubCache } from "$lib/server/github-cache";
33

44
export async function load({ params }) {
55
const { pid: type, org, repo, id } = params;
66
const numId = +id; // id is already validated by the route matcher
77

8-
const item = await gitHubCache.getItemDetails(org, repo, numId);
8+
const item = await githubCache.getItemDetails(org, repo, numId);
99
if (!item) {
1010
error(404, `${type} #${id} doesn't exist in repo ${org}/${repo}`);
1111
}

src/routes/package/releases.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PostHog } from "posthog-node";
22
import semver from "semver";
33
import type { Repository } from "$lib/repositories";
4-
import { type GitHubRelease, gitHubCache } from "$lib/server/github-cache";
4+
import { type GitHubRelease, githubCache } from "$lib/server/github-cache";
55
import type { discoverer } from "$lib/server/package-discoverer";
66
import type { Prettify } from "$lib/types";
77

@@ -35,7 +35,7 @@ export async function getPackageReleases(
3535
if (pkg.name.localeCompare(packageName, undefined, { sensitivity: "base" }) !== 0) continue;
3636

3737
// 1. Get releases
38-
const cachedReleases = await gitHubCache.getReleases({ ...repo, category });
38+
const cachedReleases = await githubCache.getReleases({ ...repo, category });
3939
console.log(
4040
`${cachedReleases.length} releases found for repo ${repo.repoOwner}/${repo.repoName}`
4141
);
@@ -45,7 +45,10 @@ export async function getPackageReleases(
4545
.filter(release => {
4646
if (!release.tag_name) {
4747
posthog?.captureException(new Error("Release with null tag_name"), undefined, {
48-
release
48+
packageName,
49+
repoOwner: repo.repoOwner,
50+
repoName: repo.repoName,
51+
...release
4952
});
5053
console.warn(`Empty release tag name: ${JSON.stringify(release)}`);
5154
return false;
@@ -66,13 +69,6 @@ export async function getPackageReleases(
6669
// 3. For each release, check if it is already found, searching by versions
6770
const { dataFilter, metadataFromTag, changelogContentsReplacer, ...rest } = repo;
6871
for (const release of validReleases) {
69-
if (!release.tag_name) {
70-
posthog?.captureException(new Error("Release with null tag_name"), undefined, {
71-
release
72-
});
73-
console.warn(`Empty release tag name: ${JSON.stringify(release)}`);
74-
continue;
75-
}
7672
const [cleanName, cleanVersion] = repo.metadataFromTag(release.tag_name);
7773
console.log(`Release ${release.tag_name}, extracted version: ${cleanVersion}`);
7874
if (foundVersions.has(cleanVersion)) continue;

src/routes/tracker/[org]/[repo]/+page.server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { error } from "@sveltejs/kit";
2-
import { gitHubCache } from "$lib/server/github-cache";
2+
import { githubCache } from "$lib/server/github-cache";
33

44
// source: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
55
const closingKeywords = [
@@ -15,16 +15,16 @@ const closingKeywords = [
1515
];
1616

1717
export async function load({ params }) {
18-
const members = await gitHubCache.getOrganizationMembers(params.org);
18+
const members = await githubCache.getOrganizationMembers(params.org);
1919
if (!members.length) error(404, `Organization ${params.org} not found or empty`);
2020

2121
const membersNames = members.map(({ login }) => login);
2222
const now = new Date();
2323

2424
const [unfilteredPRs, unfilteredIssues, unfilteredDiscussions] = await Promise.all([
25-
gitHubCache.getAllPRs(params.org, params.repo),
26-
gitHubCache.getAllIssues(params.org, params.repo),
27-
gitHubCache.getAllDiscussions(params.org, params.repo)
25+
githubCache.getAllPRs(params.org, params.repo),
26+
githubCache.getAllIssues(params.org, params.repo),
27+
githubCache.getAllDiscussions(params.org, params.repo)
2828
]);
2929
return {
3030
prs: unfilteredPRs

0 commit comments

Comments
 (0)