Add feature to use version from annotated tag#76
Merged
Conversation
Previous plugin behaviour didn't allow missing 'version.properties' file nor empty 'version' property in the file. This commit adds a behaviour that allows such configuration and deducts version from tag that code is checked out on. This functionality is useful for teams that prefer releasing 'on demand' and also allows increasing version number as needed, not based on number of commits pushed as in default behaviour with 'version' property set. To use this new simplified behaviour no other configuration option than missing 'version' is needed.
mockitoguy
reviewed
May 8, 2021
| config, projectVersion); | ||
|
|
||
| if (!config.getRequestedVersion().isPresent()) { | ||
| previousVersion = previousVersionFinder.findPreviousVersion(versions, new VersionConfig(nextVersion, config.getTagPrefix())); |
Contributor
There was a problem hiding this comment.
Can we cover this condition in the unit test?
mockitoguy
reviewed
May 8, 2021
| result = matcher.group().substring(config.getTagPrefix().length()); | ||
| explainVersion(log, result, "deducted version based on tag: '" + config.getTagPrefix() + result + "'"); | ||
| } else { | ||
| result = "0.0.1"; |
Contributor
There was a problem hiding this comment.
Can we get this code branch covered in the unit test?
mockitoguy
reviewed
May 8, 2021
| throw new ShipkitAutoVersionException( | ||
| "Please create file 'version.properties' with a valid 'version' property, " + | ||
| "for example 'version=1.0.*'", e); | ||
| System.out.println("[shipkit-auto-version] Ignoring file '" + versionFile.getName() |
Contributor
There was a problem hiding this comment.
Let's follow up with a little clean up for this, but let's not block this PR for this edge case.
mockitoguy
reviewed
May 8, 2021
| " Correct examples: 'version=1.0.*', 'version=2.10.100'"); | ||
| String v; | ||
| if (p.containsKey("version") && p.get("version").toString().trim().equals("")) { | ||
| v = null; |
Contributor
There was a problem hiding this comment.
Looks like this code branch is not covered by unit test
mockitoguy
requested changes
May 8, 2021
mockitoguy
left a comment
Contributor
There was a problem hiding this comment.
Hey! Looks great, please consider my feedback! Can you link the issue ticket to the PR description?
Increased code coverage of new feature that allows using version from annotated tag.
Contributor
Author
|
Thank you @mockitoguy for your review! I added some unit tests to increase code coverage as you requested. |
mockitoguy
approved these changes
May 8, 2021
Contributor
|
Looks great, thank you!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previous plugin behaviour didn't allow missing
version.propertiesfile nor emptyversionproperty in the file. This commit adds a behaviour that allows such configuration and deducts version from tag that code is checked out on.This functionality is useful for teams that prefer releasing "on demand" and also allows increasing version number as needed, not based on number of commits pushed as in default behaviour with
versionproperty set. To use this new simplified behaviour no other configuration option than missingversionis needed.As said implemented feature deducts version based on tag on which a code is checked out. If the tag is valid (has same prefix as configured or default 'v' and version number is valid) deducted version is same as version in tag. If other tags that are valid are found,
previousVersionwhich is exposed by the plugin, is a version with highest number less than deducted version (eg. for tagv1.1.5plugin deducts version number1.1.5and assuming that tagv1.1.4exists, exposedpreviousVersionis1.1.4). If code is not checked out on a valid tag andversionis not set as property the plugin deducts version0.0.1.To implement this behaviour getter for
requestedVersion()in'VersionConfigclass was added, and it returns Optional, which is tested inNextVersionPickerandPreviousVersionFinderclasses for containing a value, and further logic in these classes is based upon this check forrequestedVersion. AlsodeductVersion()method inAutoVersionchecks ifrequestedVersionis found in configuration, and if notpreviousVersionis being found using newly deducted version which is passed as argument tofindPreviousVersion().New behaviour is tested by two new unit tests in
NextVersionPickerTest, two tests ("no file" and "missing version property") refactored inVersionConfigTestand was also tested manually by building test project with various configuration options.This PR resolves #1