Open David-Hari opened 2 months ago
The reason why we have introduced the workflow templates was exactly to not providing any default values in code.
I think we have three options:
At this point I'm not sure what the desired solution might be for your issue. @asbjornu what do you think?
@HHobeck, I think the best option is:
Create a template which just defines a minimal set of properties
@David-Hari: May I ask you to do the changes and create a pull-request?
So what you are saying is that if a template is not used (the workflow
property is set to an empty string) then gitversion should use a minimal template instead of none?
Or are you suggesting that I create and use such a template (is that even possible)?
So what you are saying is that if a template is not used (the
workflow
property is set to an empty string) then gitversion should use a minimal template instead of none? Or are you suggesting that I create and use such a template (is that even possible)?
I think the second option is appropriated. I would say create a new template with the name e.g. default/v1 which includes a minimal set of configuration values. This template you can use for your scenario instead of an empty string.
Can you point me to the documentation on how to create my own template? I did not think that was possible.
Also, if I am to create my own template I may as well just keep the properties in my GitVersion.yml file as it's one less file to deal with. But then you should still do something about that "this should not happen, please report an issue" message in the errors.
Also, if you say that the point of the templates is to provide the default values then why do I see this here: https://github.com/GitTools/GitVersion/blob/main/schemas/6.0/GitVersion.configuration.json#L34
Seems like the code could read from there if no value is provided by the user's config file.
Looks like there is code for handling default attributes. Maybe it's just not working.
A new template mechanism was introduced to provide templates you can use in the custom configuration file. The json scheme file itselfe will be generated based on the json attribute annotation. Obviously the annotation (and also the documentation) doesn't reflect the actual implementation and needs to be updated. We don't want to have any default values in code (only in configuration template files).
A starting point might be:
docs/input/docs/workflows/
Workflows
Embedded resource
GitVersionConfiguration.cs
@arturcic: Something I've forgotten?
There is no How To yet. If you not mind please document the steps.
Thank you very much.
I think adding an test case here https://github.com/arturcic/GitVersion/blob/main/src/GitVersion.Configuration.Tests/Workflows/WorkflowsTests.cs
And unit tests for the new workflow?
@HHobeck, so you are asking me to make all these changes in the GitVersion source code right? To add a new template that contains the default values, yes?
What about my earlier comment on the existing code that appears to handle default values? You keep saying that you don't want to have any default values in code yet the above seems to indicate that it already does define the defaults in the schema json. I don't see what's wrong with that, except that it obviously isn't working at the moment.
@HHobeck, so you are asking me to make all these changes in the GitVersion source code right? To add a new template that contains the default values, yes?
Yes correct.
What about my earlier comment on the existing code that appears to handle default values? You keep saying that you don't want to have any default values in code yet the above seems to indicate that it already does define the defaults in the schema json.
What code do you mean? The JSON schema is generated from the annotation and it is just there for documenting reason.
I don't see what's wrong with that, except that it obviously isn't working at the moment.
@asbjornu Can you please elaborate?
What code do you mean? The JSON schema is generated from the annotation and it is just there for documenting reason.
The json I linked to in my earlier comment. This file.
I did not realise it was only for documentation. When I said it wasn't working I did not know that.
However, it seems like it would be a good idea to also use that json file to let the GitVersion code know about the default values. That way you still don't have to hard-code anything and you also don't need to define every single property in the templates.
When the code needs to resolve a property value (perhaps in the EffectiveConfiguration
class), it would first look in the user's config file and if not there it would look in the template and if not there it would use the default.
Anyway, that's just my opinion. I am not involved in this project so I am not going to attempt to make any changes. I will instead just leave my GitVersion.yml
file the way it is.
I would suggest, however, that you remove the "this should not happen, please report an issue" message as it can be confusing to new users who are not aware of how default values do or do not work.
We have removed the default values in code and introduced a template mechanism. That means introducing default values in code is not the desired solution here because we want to have a single source of truth. If you like you can create a template which includes a minimal set of values which can be used as a base template. Yes, I agree the annotation and the exception messages like you mentioned should be removed/changed as well.
Regards Hardy
Prerequisites
GitVersion package
GitVersion.Portable
GitVersion version
6.0.1+Branch.main.Sha.0fd23d1af997a7b7c6f22f27310443270a91fb18
Operating system
Windows
What are you seeing?
I'm just getting started with GitVersion so I'm unsure of the exact config that will suit my needs. I want my GitVersion.yml file to be minimal, without needing to specify properties when they will be the default. However, I also don't want to use any of the workflow templates, as they define specific branch config that I do not want. Therefore, I set
workflow: ''
in my config. My entire config so far looks like this:But this causes GitVersion to give an error complaining about missing values. I then set a few more properties,
This still does not satisfy GitVersion and it now complains about
tag-pre-release-weight
having no value:The documentation states that the default value for this property is 60000, so it should use that instead of forcing me to explicitly define it. Also, as you can see from the above, the error message tells me to report this issue!
What is expected?
If a property has a default value, then that value should be used if the property is not specified in the config. This really only applies when not using a workflow template.
Steps to Reproduce
Create a
GitVersion.yml
file as mentioned in the description, then rungitversion
on a repo.RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).