Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mrozanc
Copy link

@mrozanc mrozanc commented Sep 22, 2024

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 mrozanc changed the title Add an option to not have full depth when no tag matches the expression Add an option to not have full depth when no tag matches the expression and config to limit the descibe depth Sep 22, 2024
In case we have a more specific tag pattern to search on a branch,
 and this pattern does not match any tag in the branch, it's preferable
 to have a limit to the describe search for performance reasons.
As the implementation was a counter, when visiting many parents without resetting the counter,
the returned distance was not correct.

Using the DepthWalk.RevWalk has two benefits:
 - it can limit the depths
 - it allows accessing the depth of the current commit instead of trying to do it with custom code
@mrozanc
Copy link
Author

mrozanc commented Sep 22, 2024

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

 - Tags at same depth: no logic implemented to specify which one is selected, so I put one
  more commit in the test to have different depths.
 - Version from label=0 plus distance=0 (single commit, no tag), not sure why the test was expecting "1" as a version.
@qoomon qoomon self-requested a review September 23, 2024 07:13
@mrozanc mrozanc changed the title Add an option to not have full depth when no tag matches the expression and config to limit the descibe depth Add an option to not have full depth when no tag matches the expression and config to limit the describe depth Sep 25, 2024
@mrozanc mrozanc changed the title Add an option to not have full depth when no tag matches the expression and config to limit the describe depth Add an option to not have full depth when no tag matches the expression and config to limit the depth Sep 25, 2024
README.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants