Skip to content

Conversation

@gep13
Copy link
Member

@gep13 gep13 commented Jul 3, 2025

Description Of Changes

A change was made to try to make sure that everything related to
template, the name, the directories, etc are all lower case. That way,
in the absence of a StringComparer, a simple comparison can be made.
However, one of our automated tests caught a problem with this approach
when the code is checking for the defaultTemplate and whether it had
been overridden or not. This code path hadn't been ToLower'ed and as a
result, when there are uppercase letters in the path, for example the
"C:\ProgramData" location, the check would fail, and it would no longer
output that the default template had been overridden.

This commit addresses that problem by first ToLower'ing these values
ahead of the check. It also switches to using the case-insensitive
IsEqualTo method, which makes the code slightly less complicated, and
easier to follow.

Motivation and Context

Some Test-Kitchen tests were failing, which made us investigate this problem.

Testing

Tested locally, but will also re-run Test-Kitchen tests from this PR.

Operating Systems Testing

  • Windows 11

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Relates to #3694

gep13 added 2 commits July 3, 2025 15:34
In the previous commit associated with this issue:

chocolatey@1d1b180

A change was made to try to make sure that everything related to
template, the name, the directories, etc are all lower case.  That way,
in the absence of a StringComparer, a simple comparison can be made.
However, one of our automated tests caught a problem with this approach
when the code is checking for the defaultTemplate and whether it had
been overridden or not.  This code path hadn't been ToLower'ed and as a
result, when there are uppercase letters in the path, for example the
"C:\ProgramData" location, the check would fail, and it would no longer
output that the default template had been overridden.

This commit addresses that problem by first ToLower'ing these values
ahead of the check.  It also switches to using the case-insensitive
IsEqualTo method, which makes the code slightly less complicated, and
easier to follow.
The code to generate the Chocolatey CLI documentation has moved to a
new location, and this GenerateDocs.ps1 file is no longer required.
@gep13 gep13 requested a review from AdmiringWorm July 3, 2025 14:37
@gep13 gep13 changed the title Fix template issue (#3694) Fix edge case with template naming Jul 3, 2025
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

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

LGTM, but are waiting on internal Test Kitchen to finish before this PR can be merged.

@gep13
Copy link
Member Author

gep13 commented Jul 3, 2025

With @AdmiringWorm approval in place, and the Test-Kitchen tests completed, I am going to go ahead and get this merged.

@gep13 gep13 changed the base branch from develop to release/2.5.0 July 3, 2025 17:53
@gep13 gep13 merged commit b96dfab into chocolatey:release/2.5.0 Jul 3, 2025
5 checks passed
@gep13 gep13 deleted the fix-template-issue branch July 3, 2025 17:54
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.

Unable to list template information via the choco template command when template name includes capital letters

2 participants