Skip to content

Commit a7ce330

Browse files
committed
Normalise to compound entity for IBM and Red Hat
1 parent 88c37f5 commit a7ce330

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

plugins/github-enricher/sponsorFinder.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const resolveAndNormalizeCompanyName = async (company) => {
202202
}
203203
}
204204

205+
const redHatIBM = "Red Hat & IBM"
205206
const normalizeCompanyName = (company) => {
206207

207208
if (!company) return
@@ -229,9 +230,6 @@ const normalizeCompanyName = (company) => {
229230
companyName = byMatch[1]
230231
}
231232

232-
// Special case for some acquisitions
233-
companyName = companyName.replace("JBoss", "Red Hat")
234-
235233
// Special case for some URLs
236234
companyName = companyName.replace("https://www.redhat.com/", "Red Hat")
237235
companyName = companyName.replace("http://www.redhat.com/", "Red Hat")
@@ -240,6 +238,13 @@ const normalizeCompanyName = (company) => {
240238
companyName = companyName.replace(",", "")
241239
companyName = companyName?.trim()
242240

241+
242+
// Special case for some acquisitions
243+
companyName = companyName.replace("JBoss", "Red Hat")
244+
245+
companyName = companyName.replace(/^Red Hat$/, redHatIBM)
246+
companyName = companyName.replace(/^IBM$/, redHatIBM)
247+
243248
return companyName
244249
}
245250

plugins/github-enricher/sponsorFinder.test.js

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const urls = {}
1818

1919
const pactContributors = [
2020
{
21-
name: "Red Hat",
21+
name: "Orange Hat",
2222
contributions: 68,
2323
contributors: 10
2424
},
@@ -54,7 +54,7 @@ const manyContributors = [
5454
contributors: 3
5555
},
5656
{
57-
name: "Red Hat",
57+
name: "Orange Hat",
5858
contributions: 33,
5959
contributors: 5
6060
},
@@ -65,7 +65,7 @@ const manyContributors = [
6565
urls["users/redhatofficial"] = {
6666
login: "RedHatOfficial",
6767
type: "Organization",
68-
name: "Red Hat",
68+
name: "Orange Hat",
6969
company: null,
7070
}
7171

@@ -79,7 +79,7 @@ const frogNode = {
7979
"author": {
8080
"user": {
8181
"login": "someonewhoribbits",
82-
"company": "Red Hat"
82+
"company": "Orange Hat"
8383
}
8484
}
8585
}
@@ -122,7 +122,7 @@ const frogNodeDifferentCompany = {
122122
"author": {
123123
"user": {
124124
"login": "some-name",
125-
"company": "Red Hat @somewhere"
125+
"company": "Orange Hat @somewhere"
126126
}
127127
}
128128
}
@@ -232,15 +232,15 @@ describe("the github sponsor finder", () => {
232232
it("returns a list of company sponsors, given an org and project", async () => {
233233
const sponsor = await findSponsor("someorg", "someproject")
234234
expect(queryGraphQl).toHaveBeenCalled()
235-
expect(sponsor).toContain("Red Hat")
235+
expect(sponsor).toContain("Orange Hat")
236236
})
237237

238238
it("orders company sponsors by contribution level", async () => {
239239
setMinimumContributorCount(1)
240240
setMinimumContributionPercent(1)
241241
const sponsor = await findSponsor("someorg", "someproject")
242242
expect(queryGraphQl).toHaveBeenCalled()
243-
expect(sponsor).toStrictEqual(["Rabbit", "Red Hat", "Tortoise"])
243+
expect(sponsor).toStrictEqual(["Rabbit", "Orange Hat", "Tortoise"])
244244
})
245245

246246
it("filters out companies which do not have enough contributors", async () => {
@@ -278,7 +278,7 @@ describe("the github sponsor finder", () => {
278278
companyWithASingleContributor,
279279
"Occasional Company",
280280
"Another Company",
281-
"Red Hat",
281+
"Orange Hat",
282282
])
283283
})
284284

@@ -377,23 +377,31 @@ describe("the github sponsor finder", () => {
377377
})
378378

379379
it("normalises a company name with Inc at the end", async () => {
380-
const sponsor = await resolveAndNormalizeCompanyName("Red Hat, Inc")
381-
expect(sponsor).toBe("Red Hat")
380+
const sponsor = await resolveAndNormalizeCompanyName("Orange Hat, Inc")
381+
expect(sponsor).toBe("Orange Hat")
382382
})
383383

384384
it("normalises a company name with Inc. at the end", async () => {
385-
const sponsor = await resolveAndNormalizeCompanyName("Red Hat, Inc.")
386-
expect(sponsor).toBe("Red Hat")
385+
const sponsor = await resolveAndNormalizeCompanyName("Orange Hat, Inc.")
386+
expect(sponsor).toBe("Orange Hat")
387387
})
388388

389389
it("normalises a company name with a 'by' structure at the end", async () => {
390390
const sponsor = await resolveAndNormalizeCompanyName("JBoss by Red Hat by IBM")
391-
expect(sponsor).toBe("Red Hat")
391+
expect(sponsor).toBe("Red Hat & IBM")
392+
})
393+
394+
it("handles complex ownership relationships", async () => {
395+
let sponsor = await resolveAndNormalizeCompanyName("Red Hat, Inc")
396+
expect(sponsor).toBe("Red Hat & IBM")
397+
398+
sponsor = await resolveAndNormalizeCompanyName("IBM")
399+
expect(sponsor).toBe("Red Hat & IBM")
392400
})
393401

394402
it("normalises a company name with an '@' structure at the end", async () => {
395-
const sponsor = await resolveAndNormalizeCompanyName("Red Hat @kiegroup")
396-
expect(sponsor).toBe("Red Hat")
403+
const sponsor = await resolveAndNormalizeCompanyName("Orange Hat @kiegroup")
404+
expect(sponsor).toBe("Orange Hat")
397405
})
398406

399407
it("normalises a company name with a parenthetical structure at the end", async () => {
@@ -402,14 +410,14 @@ describe("the github sponsor finder", () => {
402410
})
403411

404412
it("normalises a company name with a hyphenated '@' structure at the end", async () => {
405-
const sponsor = await resolveAndNormalizeCompanyName("Red Hat - @hibernate")
406-
expect(sponsor).toBe("Red Hat")
413+
const sponsor = await resolveAndNormalizeCompanyName("Orange Hat - @hibernate")
414+
expect(sponsor).toBe("Orange Hat")
407415
})
408416

409417
it("normalises a company name with several comma-separated clauses", async () => {
410418
// This case is tricky, because we could tokenise on commas, but we only let people have one company, because otherwise the graph could be chaos.
411-
const sponsor = await resolveAndNormalizeCompanyName("Red Hat, @xlate")
412-
expect(sponsor).toBe("Red Hat")
419+
const sponsor = await resolveAndNormalizeCompanyName("Orange Hat, @xlate")
420+
expect(sponsor).toBe("Orange Hat")
413421
})
414422

415423
it("normalises a company name with several @-delimited clauses", async () => {
@@ -478,7 +486,7 @@ describe("the github sponsor finder", () => {
478486
const contributors = await getContributors("someorg", "someproject")
479487
expect(contributors.contributors).toContainEqual(expect.objectContaining({
480488
login: "link-name",
481-
company: "Red Hat"
489+
company: "Orange Hat"
482490
}))
483491
})
484492
})
@@ -502,7 +510,7 @@ describe("the github sponsor finder", () => {
502510
expect(queryGraphQl).toHaveBeenCalled()
503511
expect(contributors.companies).toHaveLength(3)
504512
expect(contributors.companies[1]).toStrictEqual({
505-
"name": "Red Hat",
513+
"name": "Orange Hat",
506514
contributions: 4,
507515
contributors: 3
508516
})

src/templates/extension-detail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ const ExtensionDetailTemplate = ({
376376
{metadata?.sourceControl?.companies && (
377377
<p><i>Company affiliations are derived from GitHub user profiles. Want your company's name to be
378378
shown in this chart? <a
379-
href={"https://hub.quarkiverse.io/checklist/#allow-your-company-to-be-named-as-a-sponsor-or-contributor-optional"}>Opt-in
379+
href={"https://hub.quarkiverse.io/checklistfornewprojects/#allow-your-company-to-be-named-as-a-sponsor-or-contributor-optional"}>Opt-in
380380
to have it included.</a></i></p>
381381
)}
382382

test-integration/detail-page.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ describe("an extension details page", () => {
6868
).resolves.toBeTruthy()
6969
})
7070

71-
// This is no longer reliable because of shifting corporate affiliations among some contributors
72-
xit("should show a sponsor", async () => {
71+
it("should show a sponsor", async () => {
7372
await expect(
7473
page.waitForSelector(`xpath///*[text()="Sponsor"]`)
7574
).resolves.toBeTruthy()

0 commit comments

Comments
 (0)