-
Notifications
You must be signed in to change notification settings - Fork 1.3k
packagekit: link Red Hat issue references in changelogs #23117
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,49 @@ function cleanupChangelogLine(text) { | |
| return text.trim(); | ||
| } | ||
|
|
||
| function isRedHatBasedDistribution() { | ||
| const os_release = cockpit.info?.os_release; | ||
| if (!os_release) | ||
| return false; | ||
|
|
||
| const ids = [os_release.ID, ...(os_release.ID_LIKE || "").split(" ")].filter(Boolean); | ||
| return ids.some(id => ["rhel", "fedora", "centos"].includes(id)); | ||
| } | ||
|
|
||
| function renderChangelogWithIssueLinks(text) { | ||
| if (!text || !isRedHatBasedDistribution()) | ||
| return text; | ||
|
|
||
| const issuePattern = /(rhbz|jira)#(\d+)/g; | ||
| const result = []; | ||
| let lastIndex = 0; | ||
| let match; | ||
|
|
||
| while ((match = issuePattern.exec(text)) !== null) { | ||
| if (match.index > lastIndex) | ||
| result.push(text.slice(lastIndex, match.index)); | ||
|
|
||
| const [, tracker, issueId] = match; | ||
| const href = tracker === "rhbz" | ||
| ? `https://bugzilla.redhat.com/show_bug.cgi?id=${issueId}` | ||
| : `https://issues.redhat.com/browse/${issueId}`; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should now be |
||
| result.push( | ||
| <a key={`${tracker}-${issueId}-${match.index}`} href={href} rel="noopener noreferrer" target="_blank"> | ||
| {match[0]} | ||
| </a> | ||
| ); | ||
| lastIndex = issuePattern.lastIndex; | ||
| } | ||
|
|
||
| if (lastIndex === 0) | ||
| return text; | ||
|
|
||
| if (lastIndex < text.length) | ||
| result.push(text.slice(lastIndex)); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| // Replace cockpit-wsinstance-https@[long_id] with a shorter string | ||
| function shortenCockpitWsInstance(list) { | ||
| return list.map(item => item.startsWith('cockpit-wsinstance-https') ? 'cockpit-wsinstance-https@.' : item); | ||
|
|
@@ -323,7 +366,8 @@ function updateItem(remarkable, info, pkgNames, key) { | |
| descriptionFirstLine = <span dangerouslySetInnerHTML={{ __html: remarkable.render(descriptionFirstLine) }} />; | ||
| description = <div dangerouslySetInnerHTML={{ __html: remarkable.render(info.description) }} />; | ||
| } else { | ||
| description = <div className="changelog">{info.description}</div>; | ||
| descriptionFirstLine = renderChangelogWithIssueLinks(descriptionFirstLine); | ||
| description = <div className="changelog">{renderChangelogWithIssueLinks(info.description)}</div>; | ||
|
Comment on lines
381
to
+383
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was checking this out now to see how it would look. There is one issue that makes me think we need to modify description for entries with markdown as well since these otherwise don't get changes. Which does create a bit of a jarring experience where some has links and some don't, or right out doesn't work at all as all changelog entries are markdown for the distro (feels like it on Fedora based on the results I get)
While we can't change everything to markdown as it would break for some packages that are supposed to be plaintext, we could modify the markdown or the HTML generated from markdown as long as it doesn't match
Probably the easiest is to detect if it's DOM in @mvollmer WDYT? |
||
| } | ||
|
|
||
| const expandedContent = ( | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can check for rhbz no matter the distro tbh. I don't think anyone else refers to their trackers as rhbz and it is quite normal to link to in regards to CVEs etc.
However, with Jira I agree that we should only link to it within RHEL-sphere, but is it common to write
jira#1234? That feels very strange to me as it doesn't include the namespace at all likeRHEL-1234.Do you have links to where the
jira#1234syntax is used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn’t find solid evidence that
jira#1234is being used; most Red Hat references I found areRHEL-1234. Should I drop the Jira part and add something likeRHEL-1234?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we use
RHEL-1234there are many many other projects in Jira, not to mention other Jira instances from other companies might have similar naming. Could you give the RH refs you found forRHEL-1234?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some I found:
https://redhat.atlassian.net/browse/RHEL-56139
https://redhat.atlassian.net/browse/RHEL-84657
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. Then lets go with that for now.
So I'd request to make