Skip to content

filter on tags on prefix or regex, to make it possible to use multiple git versions in one repository #2436

Closed
@santo2

Description

@santo2

Context

We are trying to merge a solution that build nuget packages from one repo to another.
This repo already has a tagging structure for other nuget packages. we do not want to mix up these tags.
The most obvious thing for us, seems to be able to have a filter, in which we can state a prefix or regex, so that a certain git version task, will only analyze the ones having this prefix or regex.

Other issue that we see: the analysis of the already existing tags takes about 10 minutes, because we have a lot of them. having the filter possibility, just as command git tag -l "prefix*" has, would make the analysis a lot quicker. Or is there any other way?

Solution that we think would help:

specify a prefix, that is used both for tagging and for filtering during the analysis to specify which git tag will have to be added.

Or am I missing a feature that already does this?

Activity

brendankowitz

brendankowitz commented on Nov 14, 2020

@brendankowitz

I'm looking for something similar, it looks like something like this might exist already:
https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/Model/Configuration/Config.cs#L41

tag-prefix: prefixRegex

dagophil

dagophil commented on Dec 3, 2020

@dagophil

You can put a GitVersion.yml into each project folder and use tag-prefix: '...'. For example, this folder structure should work well:

MyMonoRepo/
| FooLib/
| | GitVersion.yml (with tag-prefix: 'Foo-v')
| | [...]
| BarLib/
| | GitVersion.yml (with tag-prefix: 'Bar-v')
| | [...]

If you now run GitVersion inside the FooLib directory, it only considers Foo-v* tags and if you run it inside the BarLib directory, it only considers Bar-v* tags.

However, you will run into problems if you checkout tagged commits for one package and try to get the version of the other package. For example, if you checkout Foo-v1.2.3, GitVersion cannot compute the version of BarLib.

asbjornu

asbjornu commented on Dec 3, 2020

@asbjornu
Member

GitVersion operates on the basic principle of having one versionable entity per repository. Monorepo and similar methodologies is explicitly not supported. If you manage to get GitVersion to work in your environment regardless, please consider that a hack and not something you can be confident GitVersion will support in the future.

stale

stale commented on Mar 19, 2021

@stale

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

sebastienwarin

sebastienwarin commented on Apr 2, 2021

@sebastienwarin

Hello there,

FYI, I have forked GitVersion in Oct,2019 (based on the version 4.0), to add a new IVersionFilter called "Path filters" : https://github.com/sebastienwarin/GitVersion/commits/feature/pathfilters to include or exclude commit based on the file paths.

To use it, you have just to add in the GitVersion files the new section "paths" to include (or exclude) paths under the section "ignore" :

ignore:
  paths:
    include: 
      - MyProjectFolderA/

When GitVersion calculate the next version, the path filter check each commit to ignore those that not modifiy any files within the list.

You can add paths to "include" or to "exclude".

ignore:
  paths:
    include: 
      - MyProjectFolderA/
      - MyProjectFolderB/
    exclude: 
      - MyProjectFolderC/

I use this forked version since Oct, 2019 for all my projects, It works like a charm. I also suggest to use this with the "tag-prefix".

Take an example : you have 1 git repository with 2 projects/directories (to make it simple) :

  • MyLib/ : .NET class lib
  • MyWebApp/ : ASP.NET web app

You create one GitVersion config file (.yml) per project :

MyLib.yml :

mode: ContinuousDeployment
tag-prefix: "MyLib/"
ignore:
  paths:
    include: 
      - MyLib/

MyWebApp.yml :

mode: ContinuousDeployment
tag-prefix: "MyWebApp/"
ignore:
  paths:
    include: 
      - MyWebApp/

Then :

  • GitVersion.exe /config MyLib.yml : to generate the version for the class lib project
  • GitVersion.exe /config MyWebApp.yml : to generate the version the web app project

In the build pipelines, tag MyLib/X.X.X and MyWebApp/X.X.X after each build.

Enjoy!

asbjornu

asbjornu commented on Apr 6, 2021

@asbjornu
Member

That looks interesting, @sebastienwarin. If you are able to rebase those changes on HEAD of main, add support for file globbing to the path specs, tests for the functionality and accompanying documentation, I'd welcome a pull request adding this functionality to GitVersion.

stale

stale commented on Jul 9, 2021

@stale

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

marc-mueller

marc-mueller commented on Sep 24, 2021

@marc-mueller

The described feature looks very good and is actually exactly what we need. Is there any ETA when a PR would be ready?

asbjornu

asbjornu commented on Sep 24, 2021

@asbjornu
Member

@marc-mueller, someone would have to take @sebastienwarin's code, rebase it against GitTools:main and submit a PR.

11 remaining items

added this to the 6.x milestone on Apr 2, 2023
github-actions

github-actions commented on Sep 29, 2023

@github-actions

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

modified the milestones: 6.x, 7.x on Feb 6, 2024
smietanka

smietanka commented on Feb 7, 2025

@smietanka

@sebastienwarin wow, really cool feature that we would like to have. Is there any plan to manage this feature into GitVersion?

modified the milestones: 7.x, 6.x on Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @asbjornu@brendankowitz@santo2@arturcic@dagophil

      Issue actions

        filter on tags on prefix or regex, to make it possible to use multiple git versions in one repository · Issue #2436 · GitTools/GitVersion