Uh oh!
There was an error while loading. Please reload this page.
PowerShellForGitHub: Improve and Standardise WhatIf/Confirm Processing - #254
PowerShellForGitHub: Improve and Standardise WhatIf/Confirm Processing#254Howard Wolosky (HowardWolosky) merged 15 commits into
Conversation
Howard Wolosky (HowardWolosky)
left a comment
There was a problem hiding this comment.
A few lingering questions/nits, and then there's the need to handle the merge conflict in GitHubCore.ps1 and Telemetry.ps1 introduced by the recent change that removed Status.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Howard Wolosky (HowardWolosky)
commented
Jul 2, 2020
Also -- please let me know in what order you'd prefer your changes to go in...if you're wanting this one to go in before your other changes or after. |
Howard Wolosky (HowardWolosky)
left a comment
There was a problem hiding this comment.
After looking through this one more time, I think there is a flaw in the pattern of putting Write-InvocationLogafter the $PSCmdlet.ShouldProcess() check...there are a number of functions that do validation work and will write error messages to the console/log file in the event that there was a problem. Those lines will all print without an logged invocation entry, which could both confusing as well as detrimental (no way to review the passed-in parameters).
I think that the $PSCmdlet.ShouldProcess() checks should remain where they are, but that the Write-InvocationLog entries should go back to their original spots.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Simon Heather (X-Guardian)
commented
Jul 21, 2020
Howard Wolosky (@HowardWolosky), this is ready for the next review. |
Howard Wolosky (HowardWolosky)
left a comment
There was a problem hiding this comment.
Thanks for your patience here and all the hard work. Ready to get this merged in now.
Uh oh!
There was an error while loading. Please reload this page.
Howard Wolosky (HowardWolosky)
commented
Jul 30, 2020
/azp run PowerShellForGitHub-CI |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| Invoke-* methods share a common base code. Leaving this as-is to make this file | ||
| easier to share out with other PowerShell projects. | ||
| #> | ||
| [CmdletBinding(SupportsShouldProcess)] |
There was a problem hiding this comment.
This change is causing the tests to fail right now, because we still have the check at line 157 that calls $PSCmdlet.ShouldProcess():
Invoke-SendTelemetryEvent' calls ShouldProcess/ShouldContinue but does not have the ShouldProcess attribute.
Stack trace
at line: 157 in /home/vsts/work/1/s/Telemetry.ps1
ShouldProcess
Severity: Warning
There was a problem hiding this comment.
Removed ShouldProcessBlock
Howard Wolosky (HowardWolosky)
commented
Jul 31, 2020
/azp run PowerShellForGitHub-CI |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Howard Wolosky (HowardWolosky)
commented
Jul 31, 2020
There are 7 UT failures with this change (all 7 are consistently failing across all 4 targets, 2 additionals are one-off issues I believe). All 7 are in the GitHubBranches.tests.ps1, most likely around usage of |
Simon Heather (X-Guardian)
commented
Aug 1, 2020
Howard Wolosky (@HowardWolosky), I've remove the redundant |
Howard Wolosky (HowardWolosky)
commented
Aug 3, 2020
/azp run PowerShellForGitHub-CI |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Howard Wolosky (HowardWolosky)
commented
Aug 3, 2020
Nice to get this in. Thanks so much for spearheading this effort, Simon Heather (@X-Guardian)! |
Description
This PR improves and standardises the WhatIf/Confirm ('ShouldProcess') processing across all the functions.
Summary of changes
$PSCmdlet.ShouldProcesscheck out ofInvoke-GHRestMethodand added it to the calling functions with the correct operation and target.WhatIf:$falseandConfirm:$falseto theOut-FileCmdlet call in theWrite-Logfunction in the Helpers module. This will prevent theWrite-Logfunction displayingWhatIfandConfirmprompts.ShouldProcessfrom non-state changing functions.ShouldProcessconditions to use an early return.Set-GitHubIssueLabelfunction to removeConfirmImpact='High'and setConfirmPreferenceto 'Low' if no labels have been specified instead.Update-GitHubRepositoryfunction to removeConfirmImpact='High'and setConfirmPreferenceto 'Low' if the repo is being renamed instead.Issues Fixed
References
N/A
Checklist
Comment-based help added/updated, including examples.Changes to the manifest file follow the manifest guidance.Unit tests were added/updated and are all passing. See testing guidelines. This includes making sure that all pipeline input variations have been covered.Relevant usage examples have been added/updated in USAGE.md.If desired, ensure your name is added to our Contributors list