Skip to content
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

Add SemVerHelper.isValidSemVer(string) #811

Merged
merged 1 commit into from
May 26, 2015
Merged

Conversation

lilith
Copy link
Contributor

@lilith lilith commented May 23, 2015

Allows build scripts to check if a git tag or input string is a semver.

Allows build scripts to check if a git tag or input string is a semver.
@@ -76,6 +76,15 @@ type SemVerInfo =
0
| _ -> invalidArg "yobj" "cannot compare values of different types"


let private SemVerPattern = "^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[\da-zA-Z\-]+(?:\.[\da-zA-Z\-]+)*)?(?:\+[\da-zA-Z\-]+(?:\.[\da-zA-Z\-]+)*)?$"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be part of our normal Semver parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're saying we should throw an exception during parse for parsable but technically invalid semver strings? Int32.Parse doesn't align with the spec, particularly if we think about culture. While we can improve parse (and possibly make it more strict), some things (like prohibiting leading zeroes) are more complex without a regex.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's ask differently. Why do you need this new function? What's the use
case?
On May 25, 2015 4:40 PM, "Nathanael Jones" notifications@github.com wrote:

In src/app/FakeLib/SemVerHelper.fs
#811 (comment):

@@ -76,6 +76,15 @@ type SemVerInfo =
0
| _ -> invalidArg "yobj" "cannot compare values of different types"

+let private SemVerPattern = "^(?:0|[1-9][0-9]).(?:0|[1-9][0-9]).(?:0|[1-9][0-9])(?:-[\da-zA-Z-]+(?:.[\da-zA-Z-]+))?(?:+[\da-zA-Z-]+(?:.[\da-zA-Z-]+)*)?$"

You're saying we should throw an exception during parse for parsable but
technically invalid semver strings? Int32.Parse doesn't align with the
spec, particularly if we think about culture. While we can improve parse
(and possibly make it more strict), some things (like prohibiting leading
zeroes) are more complex without a regex.


Reply to this email directly or view it on GitHub
https://github.com/fsharp/FAKE/pull/811/files#r30982897.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it to determine if a git tag is a semver. If it's a semver, then the build can take additional actions. Very useful for continuous delivery.

forki added a commit that referenced this pull request May 26, 2015
Add SemVerHelper.isValidSemVer(string)
@forki forki merged commit ecc04a0 into fsprojects:master May 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants