qoomon / maven-git-versioning-extension

This extension will set project version, based on current Git branch or tag.
GNU General Public License v3.0
305 stars 87 forks source link

Add an option to not have full depth when no tag matches the expression and config to limit the depth #336

Open mrozanc opened 2 months ago

mrozanc commented 2 months ago

Hello, I'm very interested by your extension and I like the way we can configure it, however I see some use cases I'd need to resolve, so I propose a few pull requests with feature I could use for my pipelines.

This first one is to get the describe distance only if a matching tag was found. This way if I don't have a matching tag I have a 0 value I can work with to start a new version.

This is implemented by checking if the tag was found and proposing an additional distance value called distanceOrZero.

This is the 1st feature of 3 I need in a scenario where I want to set my RC versions on a release branch. The goal is to have a specific that acts as a marker at the start of the release branch and to use that as an expression to start incrementing RCs.

mrozanc commented 2 months ago

Added a fix for distance as it seemed incorrect for scenarios walking through many parents:

image Test here: https://github.com/mrozanc/maven-git-versioning-extension/blob/4731084a84cd288df698b14c704b7e08f7cf1cb7/src/test/java/me/qoomon/gitversioning/commons/GitUtilTest.java#L239-L277