GitVersion: always Patch incrementing, Minor is not getting incremented - semantic-versioning

I have a requirement for Automatic versioning based on branches.
I have set a tag on my master branch as 1.0.0
if changes from feature branch get merged to Master then Minor should get incremented as 1.1.0
if changes from release branch get merged to Master then Patch should be incremented as 1.1.1
but everytime when I merge the code from feature or release branch to master, the patch only get incremented, Minor is not getting incremented. Can anyone help with the branch configuration for my requirement
I have the configuration as below in GitVersion.yml file.
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
assembly-informational-format: '{InformationalVersion}'
mode: Mainline
increment: Inherit
continuous-delivery-fallback-tag: ci
tag-prefix: '\[vV\]'
major-version-bump-message: '+semver:\\s?(breaking|major)'
minor-version-bump-message: '+semver:\\s?(feature|minor)'
patch-version-bump-message: '+semver:\\s?(fix|patch)'
no-bump-message: '+semver:\\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
tag-pre-release-weight: 60000
commit-message-incrementing: Enabled
branches:
feature:
regex: ^features?\[/-\]
mode: ContinuousDeployment
tag: useBranchName
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: false
source-branches: \[\]
tracks-release-branches: true
is-release-branch: false
is-mainline: false
pre-release-weight: 0
release:
regex: ^releases?\[/-\]
mode: ContinuousDeployment
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
source-branches: \[\]
tracks-release-branches: true
is-release-branch: false
is-mainline: false
pre-release-weight: 0
ignore:
sha: \[\]
merge-message-formats: {}
update-build-number: true

Related

Getting Schema validation: Incompatible types in detekt.yml in Android Studio

Any way I can fix the schema warning in detekt.yml I am attaching the screenshot and open to add more details
Minimum reproducible detekt.yml below
build:
maxIssues: 0
excludeCorrectable: false
weights:
complexity: 2
LongParameterList: 1
style: 1
comments: 1
config:
validation: true
warningsAsErrors: true
# when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]'
excludes: ''
processors:
active: true
exclude:
- 'DetektProgressListener'
# - 'KtFileCountProcessor'
# - 'PackageCountProcessor'
# - 'ClassCountProcessor'
# - 'FunctionCountProcessor'
# - 'PropertyCountProcessor'
# - 'ProjectComplexityProcessor'
# - 'ProjectCognitiveComplexityProcessor'
# - 'ProjectLLOCProcessor'
# - 'ProjectCLOCProcessor'
# - 'ProjectLOCProcessor'
# - 'ProjectSLOCProcessor'
# - 'LicenseHeaderLoaderExtension'
style:
active: true
ReturnCount:
active: true
max: 2
excludedFunctions: 'equals'
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: true
Android version: Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 30, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Okay after some exploration I found out, in the detekt release v1.21.0 they changed all their configuration from comma-separated string to array of string in detekt.yml.
So initially it used to be excludedFunctions: 'equals, hashCode' now they have become excludedFunctions: ['equals', 'hashCode']
After detekt release v1.22.0, they started throwing error while building the project.

GitVersion jumping versions for a single untagged commit

For a single commit after a tagged commit, GitVersion Commandline suggests a version gap of 42 which coincidentally = CommitSinceVersionSource
The un-tagged commit should be 0.1.0-alpha.42 but GitVersion suggest 0.1.0-alpha0083 (i.e. previous version - 41 + CommitsSinceVersionSource - 42 = 83).
GitVersion.CommandLine
{
"Major":0,
"Minor":1,
"Patch":0,
"PreReleaseTag":"alpha.83",
"PreReleaseTagWithDash":"-alpha.83",
"PreReleaseLabel":"alpha",
"PreReleaseNumber":83,
"BuildMetaData":"",
"BuildMetaDataPadded":"",
"FullBuildMetaData":"Branch.develop.Sha.04c3569fa42b55388d8c133dbf0d3365dfda77be",
"MajorMinorPatch":"0.1.0",
"SemVer":"0.1.0-alpha.83",
"LegacySemVer":"0.1.0-alpha83",
"LegacySemVerPadded":"0.1.0-alpha0083",
"AssemblySemVer":"0.1.0.0",
"AssemblySemFileVer":"0.1.0.0",
"FullSemVer":"0.1.0-alpha.83",
"InformationalVersion":"0.1.0-alpha.83+Branch.develop.Sha.04c3569fa42b55388d8c133dbf0d3365dfda77be",
"BranchName":"develop",
"Sha":"04c3569fa42b55388d8c133dbf0d3365dfda77be",
"ShortSha":"04c3569",
"NuGetVersionV2":"0.1.0-alpha0083",
"NuGetVersion":"0.1.0-alpha0083",
"NuGetPreReleaseTagV2":"alpha0083",
"NuGetPreReleaseTag":"alpha0083",
"CommitsSinceVersionSource":42,
"CommitsSinceVersionSourcePadded":"0042",
"CommitDate":"2021-07-05"
}
GitVersion.yaml
assembly-informational-format: '{DefaultInformationalVersion}'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
branches:
master:
mode: ContinuousDelivery
tag:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: main
develop:
mode: ContinuousDeployment
tag: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: dev(elop)?(ment)?$
feature:
mode: ContinuousDeployment
tag: useBranchName
increment: Inherit
prevent-increment-of-merged-branch-version: false
ignore:
sha: []
How to solve this conundrum ? :)

What should be assembly-informational-format be set to in GitVersion.yml

My GitVersion.yml looks like below after I picked up the Global configuration from here
But the problem is, this throws the exception when I run gitversion
Unable to format AssemblyInformationalVersion. Check your format string: 'InformationalVersion' is not a member of type 'GitVersion.SemanticVersionFormatValues' (Parameter 'propertyOrFieldName')
I had to remove the 5th line
assembly-informational-format: '{InformationalVersion}'
to make the exception go away.
I tried the following but did not work.
assembly-informational-format: {InformationalVersion} # removed the quotes.
What am I missing.
next-version: 0.1.0
mode: mainline
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{InformationalVersion}'
increment: Inherit
continuous-delivery-fallback-tag: ci
tag-prefix: '[vV]'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
commit-message-incrementing: Enabled
commit-date-format: 'yyyy-MM-dd'
branches:
master:
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: ^master
tracks-release-branches: false
is-release-branch: false
release:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: ^releases?[/-]
tracks-release-branches: false
is-release-branch: true
pre-release-weight: 1000
feature:
mode: ContinuousDeployment
tag: useBranchName
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
regex: ^features?[/-]
tracks-release-branches: false
is-release-branch: false
pull-request:
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
regex: ^(pull|pull\-requests|pr)[/-]
tracks-release-branches: false
is-release-branch: false
hotfix:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
regex: ^hotfix(es)?[/-]
tracks-release-branches: false
is-release-branch: false
support:
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: ^support[/-]
tracks-release-branches: false
is-release-branch: false
develop:
mode: ContinuousDeployment
tag: unstable
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
tracks-release-branches: true
is-release-branch: false
ignore:
sha: []
merge-message-formats: {}
So, InformationalVersion is set according to the format specified by assembly-informational-format. So that's likely what's causing the error.
For example, what I've done is something like:
assembly-informational-format: '{MajorMinorPatch}{PreReleaseTagWithDash}+{ShortSha}'
Then, when I run GitVersion, I get back:
"InformationalVersion":"2.0.0-convert-to-netcore.9+abc123"
Again, the documentation is not clear on which variables can be used as part of string interpolation, vs. which variables are set by the various format fields.
UPDATE
I noticed my answer seems to contradict the documentation at GitVersion. However, my experience has demonstrated to me that setting assembly-informational-format influences the value of InformationalVersion, even though InformationalVersion is considered a variable and can be used in interpolation. I think this may be a mistake in GitVersion's documentation. Or at best, that InformationalVersion can be used as a variable in other formats, but because assembly-informational-format is what determines the final value of InformationalVersion, this variable cannot be used in the assembly-informational-format configuration value.
Another Update
OK, I realized that, while the documentation could be better, I've been operating under a misconception about what GitVersion is actually doing/providing. It's not magic (well, it kind of is ;) ), it does require work on your part.
GitVersion is merely calculating some version fields for SemVer and outputs these calculations into a JSON object when you run GitVersion.exe (when using the executable). GitVersion also provides some various common "mash-ups" of these fields, e.g. MajorMinor, MajorMinorPatch, etc. It also provides some ways for you to format complete version numbers, e.g. assembly-file-versioning-format and assembly-informational-format. But in the end, the results of all of these are output to a JSON object.
It is your responsibility to pick and choose from this JSON object, how to construct your version number. So, if you want to use the string from InformationalVersion as your NuGet package version (for v3 package feeds) which is based on the format specified in assembly-informational-format, that's your choice.
GitVersion provides instructions on how you can have this JSON object "converted" into either build variables or environment variables that can be accessed from your build process. It's up to you to ensure you configure your build to use these values to achieve your desired versioning scheme. But GitVersion only calculates the major/minor/patch version number and attempts to help you format pre-release and build metadata tags.
This revelation certainly helped me understand better how to configure GitVersion and use it in my build processes.

Versioning Nuget Package with GitVersion.yml in Azure Devops

I'm stucking with this for a whole week and I didn't reach where i wanted.
I'm thinking about having two branches:
-master
-release(we are calling it vNext - the whole company knows it by this name)
Master branch will generate the packages without prerelease tag.
Release will generate the pre release version like:
=>master is on 1.0.0
=>Create a vNext(release) branch like: vNext/1.1.0
=> Code things needed here and commit;
=> Automatically my pipeline is triggered, because I've set the trigger to branch master, vNext or vNext/*
=> I want this to create a package like (1.1.0-beta1)
=>Create a pullRequest to master
=> Automatically my pipeline is triggered,
=> I want this to create a package like (1.1.0)
This is my gitVersion.yml
next-version: 1.0
mode: Mainline
legacy-semver-padding: 0
build-metadata-padding: 0
commits-since-version-source-padding: 0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{LegacySemVer}'
branches:
master:
regex: master
increment: Patch
prevent-increment-of-merged-branch-version: true
tag: ''
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
release:
regex: vNext?[/-]
source-branches: ['master']
increment: Patch
prevent-increment-of-merged-branch-version: true
tag: beta
track-merge-target: false
tracks-release-branches: false
is-release-branch: true
I can't get this working fine. To reach where I'm now, I've already googled a lot even here in stackoverflow, but couldn't found a solution that fits in the scenario I need.
Also https://drive.google.com/open?id=1Cy-K3P4ajyUUvvtdt0oa5_NTp1FZ-UIF
This are the logs from builds
As my test, I change your yml as below.
next-version: 1.0
mode: Mainline
legacy-semver-padding: 0
build-metadata-padding: 0
commits-since-version-source-padding: 0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{LegacySemVer}'
branches:
master:
regex: master
increment: Patch
prevent-increment-of-merged-branch-version: true
tag: ''
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
release:
regex: vNext
source-branches: ['master']
increment: Patch
prevent-increment-of-merged-branch-version: true
tag: beta
track-merge-target: false
tracks-release-branches: false
is-release-branch: true
Then I get the result as this.
Hope this will help.

Ghostscript and Pantone/spotcolors

I have some pdf's for professional print that are put in a certain folder. These pdf's may or may not contain spot/Pantone colors. All files in this folder get processed.
I have to cut some white space from the edges and this works fine with Ghostscript 8.7 on a linux machine using the command:
gs \
-o correct_size.pdf \
-sDEVICE=pdfwrite \
-g1000x1000 \
-dPDFSETTINGS=/prepress \
-c "<</PageOffset [0 0]>> setpagedevice" \
-f original_size.pdf
This problem is the spot/Pantone colors aren't preserved.
The documentation speaks about handling spotcolors but doesn't really give a solution.
Has anyone come across this before or does anyone have another solution? It doesn't have to involve Ghostscript.
Using a version of Ghostscript less than 5 years old would be a good place to start!
The current version of pdfwrite will retain colour spaces, including Separation (what you are calling spot) ICCBased and DeviceN. It is also capable of retaining Separation colour spaces when converting to a different device space, by resampling the tint transform into the desired space.
Secondly, don't use the canned PDFSETTINGS unless you are very sure you understand what the settings mean. In general the default settings in pdfwrite will preserve unchanged anything in the original file that it can, the PDFSETTINGS are set to follow (as far as possible) the same settings in Adobe Acrobat Distiller. If you aren't certain what these do, the documentation details it.
If you want to know exactly, what the canned -dPDFSETTINGS=/prepress do, you can query your current version of Ghostscript with this command:
gs -q \
-dPDFSETTINGS=/prepress \
-o /dev/null \
-sDEVICE=pdfwrite \
-c "currentpagedevice {exch ==only ( ) print == } forall" \
| sort
In my case, I get this for a Ghostscript 9.16 (self-compiled from Ghostscript's current Git source respository):
/%MediaDestination 0
/%MediaSource 0
/.AlwaysEmbed []
/.HWMargins [0.0 0.0 0.0 0.0]
/.IgnoreNumCopies false
/.LockSafetyParams false
/.MarginsHWResolution [720.0 720.0]
/.MediaSize [612.0 792.0]
/.NeverEmbed []
/ASCII85EncodePages false
/AllowIncrementalCFF false
/AllowPSRepeatFunctions false
/AlwaysEmbed []
/AntiAliasColorImages false
/AntiAliasGrayImages false
/AntiAliasMonoImages false
/AutoFilterColorImages true
/AutoFilterGrayImages true
/AutoPositionEPSFiles true
/AutoRotatePages /None
/BandBufferSpace 0
/BandHeight 0
/BandWidth 0
/BeginPage {--.callbeginpage--}
/Binding /Left
/BitsPerPixel 24
/BlackPtComp 8
/BlueValues 256
/BufferSpace 4000000
/CalCMYKProfile (None)
/CalGrayProfile (None)
/CalRGBProfile (None)
/CannotEmbedFontPolicy /Error
/CenterPages false
/ColorACSImageDict -dict-
/ColorAutoFilterStrategy 248456437
/ColorConversionStrategy /LeaveColorUnchanged
/ColorImageDepth -1
/ColorImageDict -dict-
/ColorImageDownsampleThreshold 1.5
/ColorImageDownsampleType /Bicubic
/ColorImageFilter /DCTEncode
/ColorImageResolution 300
/ColorValues 16777216
/Colors 3
/CompatibilityLevel 1.5
/CompressEntireFile false
/CompressFonts true
/CompressPages true
/ConvertCMYKImagesToRGB false
/ConvertImagesToIndexed true
/CoreDistVersion 5000
/CreateJobTicket true
/DSCEncodingToUnicode []
/DefaultRenderingIntent /Default
/DetectBlends true
/DetectDuplicateImages true
/DeviceGrayToK true
/DeviceLinkProfile ()
/DoNumCopies false
/DoThumbnails true
/DocumentTimeSeq 0
/DocumentUUID ()
/DownsampleColorImages true
/DownsampleGrayImages true
/DownsampleMonoImages true
/EmbedAllFonts true
/EmitDSCWarnings false
/EncodeColorImages true
/EncodeGrayImages true
/EncodeMonoImages true
/EncryptionR 0
/EndPage {--.callendpage--}
/FastWebView false
/FirstObjectNumber 1
/FirstPage 0
/FitPages false
/ForOPDFRead false
/GraphicBlackPt 8
/GraphicICCProfile ()
/GraphicIntent 8
/GraphicKPreserve 8
/GraphicsAlphaBits 1
/GrayACSImageDict -dict-
/GrayAutoFilterStrategy 248456437
/GrayDetection false
/GrayImageDepth -1
/GrayImageDict -dict-
/GrayImageDownsampleThreshold 1.5
/GrayImageDownsampleType /Bicubic
/GrayImageFilter /DCTEncode
/GrayImageResolution 300
/GrayValues 256
/GreenValues 256
/HWResolution [720.0 720.0]
/HWSize [6120 7920]
/HaveCIDSystem false
/HaveTransparency true
/HaveTrueTypes true
/HighLevelDevice true
/ICCOutputColors ()
/ImageBlackPt 8
/ImageICCProfile ()
/ImageIntent 8
/ImageKPreserve 8
/ImageMemory 524288
/ImagingBBox null
/InputAttributes -dict-
/Install {--.callinstall--}
/InstanceUUID ()
/IsDistiller true
/KPreserve 8
/KeyLength 0
/LZWEncodePages false
/LastPage 0
/Margins [0.0 0.0]
/MaxBitmap 10000000
/MaxClipPathSize 12000
/MaxInlineImageSize 4000
/MaxPatternBitmap 0
/MaxSeparations 3
/MaxShadingBitmapSize 256000
/MaxSubsetPct 100
/MonoImageDepth -1
/MonoImageDict -dict-
/MonoImageDownsampleThreshold 1.5
/MonoImageDownsampleType /Bicubic
/MonoImageFilter /CCITTFaxEncode
/MonoImageResolution 1200
/Name (pdfwrite)
/NeverEmbed []
/NoEncrypt ()
/NoOutputFonts false
/NoT3CCITT false
/NumCopies null
/OPM 1
/OffOptimizations 0
/Optimize true
/OutputAttributes -dict-
/OutputDevice /pdfwrite
/OutputFile (/dev/null)
/OutputICCProfile (default_rgb.icc)
/OwnerPassword ()
/PDFA 0
/PDFACompatibilityPolicy 0
/PDFEndPage -1
/PDFStartPage 1
/PDFUseOldCMS false
/PDFX false
/PDFXBleedBoxToTrimBoxOffset [0.0 0.0 0.0 0.0]
/PDFXSetBleedBoxToMediaBox true
/PDFXTrimBoxToMediaBoxOffset [0.0 0.0 0.0 0.0]
/PageCount 0
/PageDeviceName null
/PageOffset [0 0]
/PageSize [612.0 792.0]
/PageUsesTransparency false
/ParseDSCComments true
/ParseDSCCommentsForDocInfo true
/PatternImagemask false
/Permissions -4
/Policies -dict-
/PreBandThreshold false
/PreserveCopyPage true
/PreserveDeviceN true
/PreserveEPSInfo true
/PreserveHalftoneInfo false
/PreserveOPIComments true
/PreserveOverprintSettings true
/PreserveSMask true
/PreserveSeparation true
/PreserveTrMode true
/PrintStatistics false
/ProcessColorModel /DeviceRGB
/ProduceDSC true
/ProofProfile ()
/ReAssignCharacters true
/ReEncodeCharacters true
/RedValues 256
/RenderIntent 8
/RotatePages false
/SeparationColorNames []
/Separations false
/SetPageSize true
/SimulateOverprint true
/SubsetFonts true
/TextAlphaBits 1
/TextBlackPt 8
/TextICCProfile ()
/TextIntent 8
/TextKPreserve 8
/TransferFunctionInfo /Preserve
/UCRandBGInfo /Preserve
/UseCIEColor false
/UseFastColor false
/UseFlateCompression true
/UsePrologue false
/UserPassword ()
/WantsToUnicode true
/sRGBProfile (None)
If you want to use -dPDFSETTINGS=/prepress, but with some tweaks of your own, you can look up the known parameters and their canned values with above command.
Then add a suitable -c ".setpdfwrite << ... >> setdistillerparams" modification to your Ghostscript command (example is arbitrary):
gs \
-dPDFSETTINGS=/prepress \
-o out.pdf \
-sDEVICE=pdfwrite \
[...more commandline switches...] \
-c ".setpdfwrite<</Optimize false/NeverEmbed[/Courier/Verdana]>>setdistillerparams" \
-f input.pdf

Resources