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

Bugfix - Correctly match package names from local repos #1731

Merged
merged 9 commits into from
Oct 22, 2024

Conversation

anamnavi
Copy link
Member

PR Summary

There was a bug in how we parse out name and version information from package file names when performing search against local repositories.

If you have a package test and test.submodule` present in the local repository their files will look like this:

`test.1.0.0.nupkg`
`test.submodule.1.0.0.nupkg`

We used WildCardPattern class before, with pattern {packageName}.*" which would pick up both packages if package testwas searched for. The code logic then assumed the rest of the part of the name would be the version so it would search through both package names and try to parsesubmodule.1.0.0` into a version.

This fix uses Regex more accurately created for the package name and to expect a version right after the name, not text.

PR Context

Fixes #1641 #1648

PR Checklist

Copy link
Member

@alerickson alerickson left a comment

Choose a reason for hiding this comment

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

Looks good, just added a couple comments

src/code/LocalServerApiCalls.cs Show resolved Hide resolved
src/code/LocalServerApiCalls.cs Outdated Show resolved Hide resolved
foreach (string path in Directory.GetFiles(Repository.Uri.LocalPath))
{
string packageFullName = Path.GetFileName(path);
MatchCollection matches = rx.Matches(packageFullName);
if (matches.Count == 0)
{
Copy link
Member

Choose a reason for hiding this comment

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

It might be nice to add logging here saying no matches were found.

Copy link
Member Author

Choose a reason for hiding this comment

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

this condition just means that as we're iterating through the files, if a file's name doesn't match it'll be reflected as matches.Count == 0 or even as groups.Count == 0. So if we added logging here it may be a lot of logs. We do have a condition after this iteration of files completes, where if the package file path latestVersionPath is empty and not set then we write an error.

@adityapatwardhan adityapatwardhan force-pushed the bugfix-versionparsefrompkg branch from cc17fb5 to 98c6809 Compare October 22, 2024 01:37
@adityapatwardhan adityapatwardhan merged commit 5bbc687 into master Oct 22, 2024
12 checks passed
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.

Error parsing version from package name for filesystem-based repository
3 participants