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

feat(version_tag): add glob support #29

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

Conversation

Thelm76
Copy link

@Thelm76 Thelm76 commented Jul 3, 2023

Adding glob(7) support for custom prefixes.

The git describe --match argument uses glob(7) pattern to match the tags.

Taking this into account, it could be useful for matching multiple tags using the same matcher :
e.g. using prefix foo?v, git can match foo_v foo-v foo!v...
Which is currently not supported by the extractVersionFromTag.

the chosen package for matching glob patterns is minimatch which is well-known and has been actively developed for more than 10 years

@Thelm76
Copy link
Author

Thelm76 commented Jul 7, 2023

Hi @damienaicheh do you think it would be possible to include such modification to the plugin?

@damienaicheh
Copy link
Owner

Hi, I dont understand your usecase, why matching multiples tags? This plugin was made to generate a package based on a specific version of your git repository

@Thelm76
Copy link
Author

Thelm76 commented Jul 10, 2023

When we use the command describe, we can use globs to match a pattern.
In our project, I tried to use the plugin to prefix a version with prefix_v1.2.3 and [email protected],
The idea was to create two tags : the two should set the version correctly, but only [email protected] would trigger the pipeline automatically.
I also tried by prefixing suffixing the tag with a dash (like prefix_v1.2.3-) but without success (it adds -0 on the version number)

The idea is to allow multiple different versions on the same commit, depending on the client we generate the app for

@Thelm76
Copy link
Author

Thelm76 commented Jul 10, 2023

By using glob patterns in the version tag, the prefix matcher becomes compatible with the --match flag thus reducing the probability of mismatch, and allowing to have multiple "different" tags working on a single pipeline.
This can be useful in multiple different case, maybe like passing a parameter in the tag name. In our case, it provides a way to chose between auto-triggering multiple pipeline, or manually launching some of them.

@@ -52,8 +53,17 @@ function run() {
originalTag = originalTag.split('\n')[0];
}
var tag = originalTag.toLowerCase();
if (tag.startsWith(splitPrefix)) {
var tagSplitted = tag.split(splitPrefix);
var prefixCandidates = Array.from({ length: tag.length }, (_, index) => tag.substring(0, index + 1));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a part I'm not sure about.
There should be a way of extracting the prefix part using the matcher, better than trying matching the prefix by gradually adding more letters and matching each candidates until it doesn't matches anymore...

@Thelm76
Copy link
Author

Thelm76 commented Jul 24, 2023

Hi @damienaicheh ,
Have you got the time to check the work I've done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants