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

Tag selector #141

Merged
merged 3 commits into from
Jun 1, 2016
Merged

Tag selector #141

merged 3 commits into from
Jun 1, 2016

Conversation

levsa
Copy link
Contributor

@levsa levsa commented May 25, 2016

Added support for a "tagSelector" closure in tag configuration, which is called to select among multiple tags on the same commit. Defaults back to selecting the last tag in the list of tags returned from scm (same behaviour as before). This allows to resolve #139 (see also discussion in #135).

Levon Saldamli added 2 commits May 25, 2016 14:20
…iple tags on a commit. Defaults back to selecting the last tag found in the list of tags returned from git, same behavior as before, i.e. when there were no list and the tag for a commit was overwritten.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 61.08% when pulling 92e3e3e on levsa:tag_selector into 6ad80bb on allegro:master.

.inject([:], { map, entry ->
if (map[entry.commit.id] == null) {
map[entry.commit.id] = [] as List<String>
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Dealing with non existing values of map can be simplified by using [:].withDefault {p -> []}

Copy link
Contributor Author

@levsa levsa May 25, 2016

Choose a reason for hiding this comment

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

I looked for something similar, but didn't find one, thanks!

That would break the null-check later on though, but it can be changed to a simple conditional if (map[id]) break;

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 61.024% when pulling 2756604 on levsa:tag_selector into 6ad80bb on allegro:master.

@adamdubiel
Copy link
Collaborator

Great stuff, thanks! Could you squash the commits before merge?

@levsa
Copy link
Contributor Author

levsa commented Jun 1, 2016

I think it can be done during merge?

https://github.com/blog/2141-squash-your-commits

I'm not sure if I can do it now that the commits are pushed already?

@adamdubiel adamdubiel merged commit 1de6a06 into allegro:master Jun 1, 2016
@adamdubiel
Copy link
Collaborator

Good call, didn't have a chance to try out this new Github Merging stuff :) Thanks once again.

@levsa
Copy link
Contributor Author

levsa commented Jun 1, 2016

Great, thank you!

@adamdubiel
Copy link
Collaborator

BTW i never release the version - now it's here: 1.3.5. Sorry it took so long :)

@dafelipe130
Copy link

Total groovy/gradle newbie here. How do you go about telling the tagSelector option to go for the default setting which is to take the tag without the 'rc' identifier?

@adamdubiel
Copy link
Collaborator

@dafelipe130 what do you mean by this? There are usually no -rc tags.. can you show the structure?

@dafelipe130
Copy link

Basically, I'm facing the same situation described here #139
In a single commit, I have both a release candidate (app-1.0.0-rc.1) and release tag (app-1.0.0). Running currentVersion with that commit as my HEAD picks up the release candidate tag instead of the release tag which is different behavior when compared to using git describe --tags --abbrev=0

@dafelipe130
Copy link

I fiddled around a bit on this one and have settled with just configuring the tagSelector to always get the first item in the tags object
tagSelector = { tags -> return tags[0] }
... which works fine with our very specific use case

However, this doesn't respect the next version marker tag if its situated in the same commit as a release/pre-release tag. The next version marker tag is not handled differently anymore and is treated as any other tag contrary to what is specified here.

This results in a scenario wherein axion reports the current version as the incremented version of the immediate release tag instead of the version specified by the next version marker.

I suppose I can add a condition to check if the last tagged commit has a next version marker then abstain the plugin from using the tagSelector option to honor said marker. Or just instruct users to first commit something then apply the marker.

Please feel free to chime in if I'm missing anything here.

@adamdubiel
Copy link
Collaborator

After analysing what you said I think bringing in tagSelector created a bit of a mess to already messy -alpha logic. What i think is that this nextVersionMarker section needs some more thinking and refactoring to make sense - i had a lot of signals about misbehaviour recently (on github and inside the company).

@adamdubiel
Copy link
Collaborator

I think i figured out some basic rules of better implementation. Current messy implementation stems from not wanting to interact with Git more than absolutely necessary, but i think that it only made the code hacky aka clever thus unmaintainable in the long run. Stay tuned :)

@adamdubiel
Copy link
Collaborator

So after some time i finally managed to refactor all the code that will make the "many tags" problem go away. The tests are green, but i want to add more integration tests to the mix. The branch is here: https://github.com/allegro/axion-release-plugin/tree/fix-tag-ordering

The main highlight is reading all tags on commit and choosing the one with the highest version. Currently there is no way to customise the behaviour and i'm not really sure it's needed - should be no problem to add it though.

After finishing work it will be released as 1.5.0, due to small API change in two places which are probably used rather rarely - custom deserializers.

@szpak
Copy link
Contributor

szpak commented Sep 18, 2016

By "many tags" problem you mean #132?

@adamdubiel adamdubiel added this to the 1.5.0 milestone Jan 20, 2017
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.

latestTag is the last rc tag instead of the non-rc tag
6 participants