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

Allow partial culture matching in Update-Help #18037

Merged

Conversation

dkaszews
Copy link
Contributor

@dkaszews dkaszews commented Sep 6, 2022

PR Summary

Allows the help locale to match, if it is in the list of parents (fallback chain) of the provided (or implicit) one.

Fixes #18021

PR Context

Currently, if the help has locale 'en-US' as most do, only the following will work and everything else will throw an error:

> Update-Help -UICulture 'en-US'
> Update-Help  # when system's culture is also "en-US"

The PR changes it so that the following will also work:

> Update-Help -UICulture 'en'
> Update-Help  # when system's culture is 'en' or child of 'en', because system culture also uses fallback chain

Explicit Update-Help -UICulture 'en-GB' will still not work, because explicit culture does not use fallback chain.

This solves the bug of fallback chain not actually working, as fallback culture 'en' did not match anything. It was supposed to work by use of globbing, but lack of + "*" meant that the glob still used exact matching. It also allows the user to use explicit -UICulture 'en' to mean "any English will do, regardless of region".

PR Checklist

@dkaszews dkaszews changed the title Allow partial culture matching in Get-Help Allow partial culture matching in Update-Help Sep 6, 2022
@dkaszews
Copy link
Contributor Author

dkaszews commented Sep 7, 2022

There is a single test failing, looks like some empty case for Save-Help I will have to investigate.

@pull-request-quantifier-deprecated

This PR has 79 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Small
Size       : +58 -21
Percentile : 31.6%

Total files changed: 5

Change summary by file extension:
.cs : +23 -20
.ps1 : +35 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@dkaszews
Copy link
Contributor Author

dkaszews commented Sep 14, 2022

Looks like the failing test case was because of a typo in AfterEach { SetTestHook("nmae", $value) }, as it ignores any hook whose name it cannot find. What is the reasoning behind it? Can I make a non-breaking change for it to return fieldInfo != null; saying if it successfully set or not, that the caller can then check, or should I avoid making changes not strictly related to this change?`

@iSazonov
Copy link
Collaborator

or should I avoid making changes not strictly related to this change?`

Unrelated and style changes should be moved to separate PRs.

@ghost ghost added the Review - Needed The PR is being reviewed label Sep 22, 2022
@ghost
Copy link

ghost commented Sep 22, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@dkaszews
Copy link
Contributor Author

@adityapatwardhan Can I please get this one reviewed? I previously got approve from you on #17780 , this one is related. Getting a bit dusty 😅

@daxian-dbw
Copy link
Member

@adityapatwardhan Can you please review this PR?

@ghost ghost removed the Review - Needed The PR is being reviewed label Apr 10, 2023
@ghost ghost added the Review - Needed The PR is being reviewed label Apr 18, 2023
@ghost
Copy link

ghost commented Apr 18, 2023

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@dkaszews dkaszews mentioned this pull request Apr 29, 2023
22 tasks
@doctordns
Copy link
Contributor

I will bring this up in the next Cmdlet WG meeting this week. No promises, but I'll try!

@doctordns
Copy link
Contributor

The Cmdlet working group has reviewed this PR and agrees with the proposed behaviour. There is possibly a wider discussion to be had over help fallback culture in general.

@daxian-dbw daxian-dbw added the CommunityDay-Small A small PR that the PS team has identified to prioritize to review label May 8, 2023
/// zh-Hans-CN => { zh-Hans-CN, zh-Hans, zh }.
/// </example>
/// <returns>An enumerable list of culture names.</returns>
internal static IEnumerable<string> GetCultureFallbackChain(CultureInfo culture)
Copy link
Member

Choose a reason for hiding this comment

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

One of the issues is that on Ubuntu 20+, the default culture is set as C.UTF-8.
It doesn't have 'en' in its parent chain. Can we accommodate for cases like that? If a matching culture is not found fallback to en-US?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adityapatwardhan Interesting case, but out of scope. From my skimming of the POSIX standard, C.UTF-8 is more of a default null culture and in no way equivalent to en-US. In fact, presuming everyone uses en-US is the very source of the issues I am attempting to fix.

Source issue shows the error that will be shown, I think it is well good enough:

Update-Help: Failed to update Help for the module(s) 'Microsoft.PowerShell.Core' with UI culture(s) {C}:
Unable to retrieve the HelpInfo XML file for UI culture C.
Make sure the HelpInfoUri property in the module manifest is valid or check your network connection and then try the command again..
English-US help content is available and can be installed using: Update-Help -UICulture en-US.

I could specialise the error message to also show something like "Your culture is C.UTF-8, which is a default not associated with any language, consider changing your system culture", but please create another issue for it so that it can be discussed.

Copy link
Member

@adityapatwardhan adityapatwardhan May 9, 2023

Choose a reason for hiding this comment

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

I think the updated error message is much better than the current one. It would be great if you could do that. I will open a issue for that.

Copy link
Member

Choose a reason for hiding this comment

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

Here: #19633

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 8, 2023
@ghost ghost removed Review - Needed The PR is being reviewed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels May 8, 2023
@adityapatwardhan adityapatwardhan merged commit 270f8f1 into PowerShell:master May 9, 2023
@adityapatwardhan adityapatwardhan added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label May 9, 2023
@adityapatwardhan
Copy link
Member

@dkaszews Thank you for your contribution!

@sdwheeler sdwheeler added the PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed label Jun 1, 2023
@sdwheeler
Copy link
Collaborator

@dkaszews
Copy link
Contributor Author

dkaszews commented Jun 7, 2023

Created MicrosoftDocs/PowerShell-Docs#10148

@ghost
Copy link

ghost commented Jun 29, 2023

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-Engine Indicates that a PR should be marked as an engine change in the Change Log CommunityDay-Small A small PR that the PS team has identified to prioritize to review PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update-Help does not work with partial locale
6 participants