Improve wildcard search for conan package name and version

What does this MR do and why?

Improve wildcard search for conan package name and version. This fixes part of #507340 (closed). The wildcards for username and channel will be handled in another mr.

We were unsure if we need to add another index to the database since we added the with_version_like search on the package.

Co-Authored-By: @oceane_scania

References

How to set up and validate locally

Supposing you have a conan remote called "gitlab-local" pointing to your local gitlab project. If not, you can set it up following the documentations: https://docs.gitlab.com/ee/user/packages/conan_repository/#add-a-remote-for-your-project

  1. Create a new conan package

    mkdir searchTestpkg && cd searchTestpkg
    conan new searchTest/1.2.3@gitlab-org+conan/stable --template=cmake_lib
    conan create . gitlab-org+conan/stable
  2. Upload the package

    conan upload searchTest/1.2.3@gitlab-org+conan/stable -r gitlab-local --all
  3. Search for the package

    conan search s*chT*t/1.*.3@gitlab-org+conan/stable -r gitlab-local

    Conan should return:

    Existing package recipes:
    
    searchTest/1.2.3@gitlab-org+conan/stable
  4. Validate error handling

    Long search term:

    conan search "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq" -r gitlab-local

    Conan should return:

    ERROR: {"message":"Search term length must be less than 200 characters."}. [Remote: gitlab-local]

    Too many wildcards in search term:

    conan search "al*h*/*@*nn*/*" -r gitlab-local

    Conan should return:

    ERROR: {"message":"Too many wildcards in search term. Maximum is 5."}. [Remote: gitlab-local]

Related to #507340 (closed)

cc @oceane_scania

Edited by Mariana Bocoi

Merge request reports

Loading