Skip to content

Commit 53034c1

Browse files
committed
change that introduces fix to issue 93
1 parent 4da25dd commit 53034c1

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/__tests__/unit/main.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@ describe("getMetaData", () => {
5454
expect(result.feedbackMechanism).toContain("/issues");
5555
});
5656

57+
it("preserves existing languages over GitHub-detected languages", async () => {
58+
const deps = createMockDeps();
59+
const helpers = createHelpers(deps);
60+
61+
const existing = {
62+
...validCodeJSON,
63+
languages: ["TypeScript", "Markdown"],
64+
} as any;
65+
const result = await getMetaData(helpers, deps, existing);
66+
67+
expect(result.languages).toEqual(["TypeScript", "Markdown"]);
68+
});
69+
70+
it("falls back to GitHub-detected languages when none exist", async () => {
71+
const deps = createMockDeps();
72+
const helpers = createHelpers(deps);
73+
74+
const result = await getMetaData(helpers, deps, null);
75+
76+
expect(result.languages).toEqual(["TypeScript", "JavaScript"]);
77+
});
78+
5779
it("sets Archival status when isArchived", async () => {
5880
const deps = createMockDeps({ isArchived: true });
5981
const helpers = createHelpers(deps);

src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ async function getMetaData(
112112
? partialCodeJSON.description
113113
: existingCodeJSON?.description || "";
114114

115+
// preserve manually curated languages when they already exist in code.json,
116+
// and only fall back to GitHub detected languages for new repositories.
117+
const languages =
118+
existingCodeJSON?.languages && existingCodeJSON.languages.length > 0
119+
? existingCodeJSON.languages
120+
: partialCodeJSON.languages;
121+
115122
// only update tags if we have new ones from GitHub Topics, otherwise keep existing
116123
const shouldUpdateTags =
117124
partialCodeJSON.tags && partialCodeJSON.tags.length > 0;
@@ -155,7 +162,7 @@ async function getMetaData(
155162
repositoryURL: partialCodeJSON.repositoryURL,
156163
repositoryVisibility: partialCodeJSON.repositoryVisibility,
157164
laborHours: partialCodeJSON.laborHours,
158-
languages: partialCodeJSON.languages,
165+
languages: languages,
159166
reuseFrequency: {
160167
forks: partialCodeJSON.reuseFrequency?.forks ?? 0,
161168
clones: existingCodeJSON?.reuseFrequency?.clones ?? 0,

0 commit comments

Comments
 (0)