pdm-project / pdm-backend

The build backend used by PDM that supports latest packaging standards.
https://backend.pdm-project.org
MIT License
70 stars 39 forks source link

Add tag filter #225

Closed mezuzza closed 7 months ago

mezuzza commented 8 months ago

This PR adds tag_filter as a metadata property which can be used to filter the set of tags examined for versioning the project. More details can be found in #219.

The git changes in this PR are straightforward. The hg changes require a bit more context.

In order to tags, it was necessary to use hg log as it provides a --template argument to use with the latesttag function. Technically hg's regex is a python style regex, but I didn't think it prudent to depend on that exact implementation detail. Instead, I refactored the implementation slightly so that we use hg log to extract the current commit and hg id is relegated to telling us if the working tree is dirty.

This is a PR that's stacked on top of #224. For easy of review, I suggest you look at only the most recent commit. All other changes are captured in #224.

Resolves #219

netlify[bot] commented 8 months ago

Deploy Preview for pdm-backend-docs ready!

Name Link
Latest commit ea2afd03de8198f5f18ede3e5ae781e64c0ebd0d
Latest deploy log https://app.netlify.com/sites/pdm-backend-docs/deploys/662fec35e96dc80008a2077e
Deploy Preview https://deploy-preview-225--pdm-backend-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

mezuzza commented 8 months ago

This is still missing tests. I thought I'd ask for an early review of the draft just to align on the approach.

I'll finish the tests next week and submit for review.

mezuzza commented 7 months ago

Sure, I'm used to stacking changes and submitting only once the parent has been submitted. I'll pull the changes out this week and separate them.

Also, sorry for the delay, but I've been pretty busy and hadn't the time to get to this. Will do so in the next couple days.

frostming commented 7 months ago

You forgot to declare pytest_lazyfixture as a dependency

mezuzza commented 7 months ago

I'm confused. It's a part of the test dependencies in the pyproject.toml. Does it need to be elsewhere?

image
frostming commented 7 months ago

I'm confused. It's a part of the test dependencies in the pyproject.toml. Does it need to be elsewhere?

image

According to the README, you don't need to import anything, as it can be accessed via pytest.lazy_fixture

mezuzza commented 7 months ago

Just tried that. It unfortunately fails pyright as pytest.lazy_fixture is parsed as an object. I'm not sure if it would pass mypy or pyre.

Do you care about the type checker and do you have a preference here? I'd recommend just leaving it as is since it will reduce type issues in the future compared to pytest.lazy_fixture.

frostming commented 7 months ago

Do you care about the type checker and do you have a preference here? I'd recommend just leaving it as is since it will reduce type issues in the future compared to pytest.lazy_fixture.

As long as the CI statuses are all green I am ok

mezuzza commented 7 months ago

Done. Added a quick assertion, but otherwise it should be good.

frostming commented 7 months ago

Please rebase main branch

mezuzza commented 7 months ago

Done

mezuzza commented 7 months ago

I noticed that the tests were failing so I took a look. Turns out that they were failing because of two issues.

  1. pytest.lazy_fixture wasn't working, so I swapped back to the explicit import.
  2. ZoneInfo wasn't available until python 3.9, so 3.8 was failing. This has been fixed by using dateutil for the time zone.
mezuzza commented 7 months ago

Removed the pytest-lazy-fixture dependency and fixed the CI to install hg for use in testing. All the tests are passing now.