-
Notifications
You must be signed in to change notification settings - Fork 899
Improve CanRetrieveValidVersionString() #697
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
Conversation
string versionInfo = Repository.Version; | ||
|
||
Assert.NotNull(versionInfo); | ||
|
||
bool matched = Regex.IsMatch(versionInfo, @"^\d{1,}\.\d{1,2}\.\d{1,3}-\w+-\w+ \(\w+ - (?:\w*(?:, )*\w+)*\)$"); |
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 wonder if we should structure this test as an example of how to extract version information with regex groups, e.g. "^(?<version>[\d\.]+)-(?<lg2s>\w+)-(?<lg2>\w+) \((?<arch>\w+) - (?<features>.+)\)$"
.
Then in addition to asserting a pattern match, we can assert that the various captured values aren't empty?
While we're here, I noticed libgit2/libgit2#2150 explicitly switches from "capabilities" to "features" to avoid confusion. Our documentation of the |
Something like: http://rubular.com/r/M3N5oHXxFt |
Works for me |
string versionInfo = Repository.Version; | ||
|
||
// The Repository.Version returned string should contain : | ||
// version:'0.17.0' LibGit2Sharp version number. | ||
// git2SharpHash:'unknown' ( Why is this unknown? ) LibGit2Sharp library hash. |
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.
unknown
when built from the source code. Otherwise (when relying on a NuGet package for instance), will be the short sha of the LibGit2Sharp commit the assembly has been built from.
in RepositoryFixture Updated Repository.Version documentation Updated Repository.Version test regex now checks each group. Fixes libgit2#696
@someoneigna You're on a roll! ✨ ✨ ✨ |
Thanks for starting me on this 😄. It's very engaging and entertaining 👍 |
Enforces Major.Minor.Patch-LibGit2Sharp_abbrev_hash-libgit2_abbrev_hash (x86|amd64 - capabilities) format.
The regex is based on the output I'm getting from Repository.Version, "0.17.0-unknown-06d772d (x86 - Threads, Https)".