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
Bug: Branch contains / is not replaced by - in build metadata #1520
Comments
Any update on this? NuGet 4.3.0 (and higher with support for SemVer 2.0) actually has issues with this. And according to the Semantic Versioning 2.0.0 spec '/' isn't an allowed character.
|
@arturcic i'm not sure if you are the correct person to tag into this. But for the moment you seem to be the most active in this repo. |
Fixed by #1704. |
this still seems to be an issue if you overwrite the assembly-informational-format. Take the following format defined in the yml: I get the following: |
The fix was included in version 5.0.0. This version has only been released 14d ago. |
I'm still getting this issue as mentioned by @andrewescutia. I'm running GitVersion version 5.1.2 through MSBuild. I have the following in my GitVersion.yml:
The output is:
What I'm really trying to achieve is to have the exact same |
Can you see anything wrong with the regex GitVersion/src/GitVersionCore/SemanticVersioning/SemanticVersionBuildMetaData.cs Lines 163 to 168 in 5d6ed2a
|
The think confusion is between the SemanticVersion and the other variables (in this case InformationalVersion). At first glance i don't believe there is a configuration option to change the SemanticVerion format. |
I have created this PR that resolves the issue for the BranchName variable: #2008 This seems to do exactly what I need. |
@KiLLeRRaT If i understand it correctly the problem is that you use the informational assembly version as SemVer because you need a shorter version of the default SemVer outputted by GitVersion. The correct extension would be to add a configuration setting so the SemVersion format can be changed. And in the SemVer special chars aren’t allowed and get replaces by dashes. |
@asbjornu I don't see anything wrong with the RegEx. I don't think this method is called for the BranchName variable though. If you look at
The only place the code referenced by @asbjornu is called in from within this ToString method. |
@Skoucail, your comment makes sense. That leaves us with this problem though. I'm guessing we could do something like wrap
FormatMetaDataPart e.g.:
I haven't tried this though. |
Well depends on the opinions i guess. Only the outputted SemVer isn’t allowed to contain special slaches. The thing missing in GitVersion is the ability to set the SemVer format. While the informational version format can be set but doesn’t impact the generated SemVer. |
Hi @Skoucail , Is the SemVer that is set agains the assembly coming straight from If I change that format
then my output dll contains that. Are you saying that we should implement another configurable format and output, so instead of using The Cheers, |
Sorry i was a bit confused yesterday. GitVersion/src/GitVersionCore/OutputVariables/VariableProvider.cs Lines 56 to 59 in c2005e1
The code for semverFormatValues.DefaultInformationalVersion is:
So if the default is used they use the ToString function that got changed/fixed in my pull request. GitVersion/src/GitVersionCore/OutputVariables/VariableProvider.cs Lines 110 to 131 in c2005e1
I still believe changing the BranchName to replace special characters with daches would for some people break their systems/setups. So we need a more sophisticated fix for this issue that only affects the InformationalVersion. |
I believe the fix with the least impact is adding RegexReplace("[^0-9A-Za-z-.+]", "-") to the result of CheckAndFormatString for informationalVersion. Any thoughts?
|
I agree that sounds like the most narrow-scoped solution, @Skoucail. Would you or @KiLLeRRaT be up for a PR that implements this with at least one test that ensures the reported bug is fixed? |
… when a custom format is used.
I already made some tests to debug the issue. |
Thanks everyone for helping with this. Much appreciated. |
@KiLLeRRaT your welcome @asbjornu Do you have an idea when this fix will be released to stable? |
@Skoucail, we don't plan releases, but I suppose we could get a v5.1.4 or 5.2 out the door some time soon. |
Hi Guys, I could finally test this after other build issues were merged in. I'm using I have the following set in my GitVersion.yml: assembly-informational-format: '{Major}.{Minor}.{Patch}+{CommitsSinceVersionSource}.Branch.{BranchName}.Sha.{ShortSha}' This still outputs with a slash in the branch name InformationalVersion: 20.1.24+7.Branch.feature/20200224_UpgradeGitVersionTask.Sha.6285b41 Here is the full output: Major: 20
Minor: 1
Patch: 24
PreReleaseTag: 20200224-UpgradeGitVersionTask.1
PreReleaseTagWithDash: -20200224-UpgradeGitVersionTask.1
PreReleaseLabel: 20200224-UpgradeGitVersionTask
PreReleaseNumber: 1
WeightedPreReleaseNumber: 30001
BuildMetaData: 7
BuildMetaDataPadded: 0007
FullBuildMetaData: 7.Branch.feature-20200224-UpgradeGitVersionTask.Sha.6285b41097704a6a585c06f7a0247ff6d654d738
MajorMinorPatch: 20.1.24
SemVer: 20.1.24-20200224-UpgradeGitVersionTask.1
LegacySemVer: 20.1.24-20200224-UpgradeGit1
LegacySemVerPadded: 20.1.24-20200224-Upgrade0001
AssemblySemVer: 20.0.0.0
AssemblySemFileVer: 20.1.24.0
FullSemVer: 20.1.24-20200224-UpgradeGitVersionTask.1+7
InformationalVersion: 20.1.24+7.Branch.feature/20200224_UpgradeGitVersionTask.Sha.6285b41
BranchName: feature/20200224_UpgradeGitVersionTask
Sha: 6285b41097704a6a585c06f7a0247ff6d654d738
ShortSha: 6285b41
NuGetVersionV2: 20.1.24-20200224-upgrade0001
NuGetVersion: 20.1.24-20200224-upgrade0001
NuGetPreReleaseTagV2: 20200224-upgrade0001
NuGetPreReleaseTag: 20200224-upgrade0001
VersionSourceSha: 5c6d1c3fa8aca9b478c5dc14e14cb10f20aa5950
CommitsSinceVersionSource: 7
CommitsSinceVersionSourcePadded: 0007
CommitDate: 2020-03-04
If I run it without the custom format in InformationalVersion: 20.1.24-20200224-UpgradeGitVersionTask.1+7.Branch.feature-20200224-UpgradeGitVersionTask.Sha.6285b41097704a6a585c06f7a0247ff6d654d738 The above is correct, but way too long and Azure Pipelines/Octopus Deploy complains that the version string is too long. As mentioned earlier, I need to make my own I still need to get a branch name that doesn't contain a slash from somewhere. Any ideas? Should I just implement another variable called Cheers |
It would be wrong to modify |
Here you go: #2157 |
GitVersion version: 4.0, 3.6.4
Problem:
Given a branch name contains
/
, e.g.hotfixes/build-script
, the build metadata does not convert it to hyphen. This is not a valid semver 2.The text was updated successfully, but these errors were encountered: