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

Add PreferDefaultName property #5744

Merged
merged 21 commits into from
Dec 31, 2022
Merged

Conversation

maridematte
Copy link
Contributor

@maridematte maridematte commented Dec 9, 2022

Problem

This is for Issue 2303.

Solution

Adding support for PreferDefaultName optional property in template.json. The property defines which name should be used as a fallback option when the -name option is not passed in template creation.

  • If true the engine will use the DefaultName of the template.
  • If false the engine will use the folder's name.

Checks:

  • Added unit tests
  • Added #nullable enable to all the modified files ?

@dnfadmin
Copy link

dnfadmin commented Dec 9, 2022

CLA assistant check
All CLA requirements met.

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Looks good!

Tests will be needed - you can add them to TemplateCreatorTests. (after #5677 is merged, it'll be possible to add snapshot tests as well - but for now best option is TemplateCreatorTests or IDE.IntegrationTests)

Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

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

Looks very good, great work! Left couple of comments inline.

The following bits are missing:

@maridematte maridematte marked this pull request as ready for review December 16, 2022 01:08
@maridematte maridematte requested review from a team and baronfel as code owners December 16, 2022 01:08
Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

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

Looks good!

Couple of comments and suggestions for additional tests.

Could you please investigate behavior: what is the error in this case: no defaultName is specified and preferDefaultName is set to true? Maybe consider End2End test.

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Looks solid to me - good job!

I added few comments o consider for making test code more conscise.
You can probably as well use templates test FW (via passing explicit null as name parameter).
After this is merged please create PR in schemastore to reflect your changes there as well - https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/template.json

Overall it's great!!

Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to go.
Just a small casing issue in the error message

@vlada-shubina
Copy link
Member

/backport to release/7.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/7.0.2xx: https://github.com/dotnet/templating/actions/runs/3947472630

@github-actions
Copy link
Contributor

@vlada-shubina backporting to release/7.0.2xx failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Base of PreferDefaultName
Using index info to reconstruct a base tree...
M	src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
M	src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
M	src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs
M	src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs
M	src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs
M	src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs
M	test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs
Falling back to patching base and 3-way merge...
Auto-merging test/Microsoft.TemplateEngine.Mocks/MockTemplateInfo.cs
Auto-merging src/Microsoft.TemplateSearch.Common/TemplateDiscoveryMetadata/BlobStorageTemplateInfo.cs
Auto-merging src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ConfigModel/TemplateConfigModel.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/Template/TemplateCreator.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/Settings/TemplateInfo.cs
Auto-merging src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Microsoft.TemplateEngine.Edge/PublicAPI.Unshipped.txt
Auto-merging src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Microsoft.TemplateEngine.Abstractions/PublicAPI.Unshipped.txt
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Base of PreferDefaultName
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@vlada-shubina an error occurred while backporting to release/7.0.2xx, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

YuliiaKovalova pushed a commit to YuliiaKovalova/templating that referenced this pull request Jan 18, 2023
Adding support for PreferDefaultName optional property in template.json
Co-authored-by: Jan Krivanek <jankrivanek@microsoft.com>
YuliiaKovalova added a commit that referenced this pull request Jan 19, 2023
Adding support for PreferDefaultName optional property in template.json
Co-authored-by: Jan Krivanek <jankrivanek@microsoft.com>

Co-authored-by: Mariana Dematte <magarces@microsoft.com>
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.

4 participants