Skip to content

Optional prefix to filter Git tags relevant to Copier #2119

Open
@emcd

Description

@emcd

Actual Situation

I maintain the following in the same repository:

  • Copier Template: copier.yaml, template/**
  • Common Github Workflows: .github/workflows/xrepo--*.yaml
  • Common Documentation: documentation/common/*.rst
  • Project Maintenance Package: sources/** (static website generation for index of per-version documentation/coverage reports, code coverage badge/shield generation, release process helpers, etc...)

These exist in the same repository so that they can be updated in lock-step, when necessary.

  • E.g., the Copier template generates project-specific Github workflows which rely on the common workflows.
  • E.g., the common workflows rely on some of the tooling provided by the project maintenance package published on PyPI.
  • E.g., the Copier template generates project-specific documentation stubs which reference the common documentation.

I have the common documentation independently versioned with docs-* Git tags and will be doing the same for the common Github workflows soon (gha-* tags). However, I am in a situation where new releases of the Copier template also trigger new releases of the PyPI package and vice versa, because they currently share the same set of tags, out of necessity. While it is true that I could exclude the Copier template paths from the Github workflow trigger for releases, there are still two issues with that:

  • it can lead to non-contiguous package release versions, if Copier template releases occur between Python package releases;
  • the repository itself, including a release management Github workflow, is generated from the Copier template that it contains and the Copier template does not (and should not) have special logic for this case.

Desired Situation

To me, the cleanest solution would be for Copier to support a tag filter prefix. E.g., if I gave a copier- prefix during copier copy, then it would look for the latest tag starting with copier-. The prefix would be recorded as a new underscore variable in the answers file.

Proposed solution

(Same as desired situation.)

I looked at copier/_vcs.py and it seems that an additional parameter for the prefix would need to be plumbed into checkout_latest_tag. Then, if a prefix is supplied, a filter would need to be applied before the valid_version filter. Seems like a fairly small change, even including tests and documentation updates.

I can make a PR, but does this idea have maintainer approval? (Happy to discuss my use case in more detail, if it is not clear.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions