-
Notifications
You must be signed in to change notification settings - Fork 451
Fix parsing of GHES pre-release versions #2969
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1132,6 +1132,14 @@ export function checkActionVersion( | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export function parseGhesVersion(version: string): semver.SemVer { | ||||||||||||||||||||||||||||||||||||
| // GHES pre-release versions are in the format "3.18.0.pre1", which is not a valid semver version. | ||||||||||||||||||||||||||||||||||||
| if (version.includes(".pre")) { | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| if (version.includes(".pre")) { | |
| if (/\.pre\d+$/.test(version)) { |
Copilot
AI
Jul 14, 2025
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.
Using replace(".pre", "-pre") only replaces the first occurrence. If there could be multiple .pre patterns in a version string, consider using replaceAll() or a global regex. However, if only one occurrence is expected, this is acceptable.
| version = version.replace(".pre", "-pre"); | |
| version = version.replaceAll(".pre", "-pre"); |
Copilot
AI
Jul 14, 2025
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.
The function doesn't handle potential errors from new semver.SemVer(version). If the version string is still invalid after transformation, this will throw an exception. Consider adding error handling or documenting this behavior.
| export function parseGhesVersion(version: string): semver.SemVer { | |
| // GHES pre-release versions are in the format "3.18.0.pre1", which is not a valid semver version. | |
| if (version.includes(".pre")) { | |
| version = version.replace(".pre", "-pre"); | |
| } | |
| return new semver.SemVer(version); | |
| export function parseGhesVersion(version: string): semver.SemVer | null { | |
| // GHES pre-release versions are in the format "3.18.0.pre1", which is not a valid semver version. | |
| if (version.includes(".pre")) { | |
| version = version.replace(".pre", "-pre"); | |
| } | |
| try { | |
| return new semver.SemVer(version); | |
| } catch (error) { | |
| core.warning(`Invalid GHES version string: ${version}. Error: ${error}`); | |
| return null; | |
| } |
Uh oh!
There was an error while loading. Please reload this page.