A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/PowerShellForGitHub/commit/2f16de1f46611a89cd833429f6227c83b5563e84 below:

Improve and Standardise WhatIf/Confirm Processin… · microsoft/PowerShellForGitHub@2f16de1 · GitHub

@@ -97,11 +97,8 @@ filter Get-GitHubRepositoryBranch

97 97

again. This tries to show some of the different types of objects you can pipe into this

98 98

function.

99 99

#>

100 -

[CmdletBinding(

101 -

SupportsShouldProcess,

102 -

DefaultParameterSetName='Elements')]

100 +

[CmdletBinding(DefaultParameterSetName = 'Elements')]

103 101

[OutputType({$script:GitHubBranchTypeName})]

104 -

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification="Methods called within here make use of PSShouldProcess, and the switch is passed on to them inherently.")]

105 102

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "", Justification="One or more parameters (like NoStatus) are only referenced by helper methods which get access to it from the stack via Get-Variable -Scope 1.")]

106 103

[Alias('Get-GitHubBranch')]

107 104

param(

@@ -237,9 +234,6 @@ filter New-GitHubRepositoryBranch

237 234

PositionalBinding = $false

238 235

)]

239 236

[OutputType({$script:GitHubBranchTypeName})]

240 -

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '',

241 -

Justification = 'Methods called within here make use of PSShouldProcess, and the switch is

242 -

passed on to them inherently.')]

243 237

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '',

244 238

Justification = 'One or more parameters (like NoStatus) are only referenced by helper

245 239

methods which get access to it from the stack via Get-Variable -Scope 1.')]

@@ -291,8 +285,6 @@ filter New-GitHubRepositoryBranch

291 285

OwnerName = $OwnerName

292 286

RepositoryName = $RepositoryName

293 287

BranchName = $BranchName

294 -

Whatif = $false

295 -

Confirm = $false

296 288

}

297 289

if ($PSBoundParameters.ContainsKey('AccessToken'))

298 290

{

@@ -338,6 +330,11 @@ filter New-GitHubRepositoryBranch

338 330

sha = $originBranch.commit.sha

339 331

}

340 332 333 +

if (-not $PSCmdlet.ShouldProcess($BranchName, 'Create Repository Branch'))

334 +

{

335 +

return

336 +

}

337 + 341 338

$params = @{

342 339

'UriFragment' = $uriFragment

343 340

'Body' = (ConvertTo-Json -InputObject $hashBody)

@@ -431,9 +428,6 @@ filter Remove-GitHubRepositoryBranch

431 428

DefaultParameterSetName = 'Elements',

432 429

PositionalBinding = $false,

433 430

ConfirmImpact = 'High')]

434 -

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "",

435 -

Justification = "Methods called within here make use of PSShouldProcess, and the switch is

436 -

passed on to them inherently.")]

437 431

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "",

438 432

Justification = "One or more parameters (like NoStatus) are only referenced by helper

439 433

methods which get access to it from the stack via Get-Variable -Scope 1.")]

@@ -468,6 +462,8 @@ filter Remove-GitHubRepositoryBranch

468 462

[switch] $NoStatus

469 463

)

470 464 465 +

Write-InvocationLog

466 + 471 467

$elements = Resolve-RepositoryElements

472 468

$OwnerName = $elements.ownerName

473 469

$RepositoryName = $elements.repositoryName

@@ -484,23 +480,23 @@ filter Remove-GitHubRepositoryBranch

484 480

$ConfirmPreference = 'None'

485 481

}

486 482 487 -

if ($PSCmdlet.ShouldProcess($BranchName, "Remove Repository Branch"))

483 +

if (-not $PSCmdlet.ShouldProcess($BranchName, "Remove Repository Branch"))

488 484

{

489 -

Write-InvocationLog

490 - 491 -

$params = @{

492 -

'UriFragment' = $uriFragment

493 -

'Method' = 'Delete'

494 -

'Description' = "Deleting branch $BranchName from $RepositoryName"

495 -

'AccessToken' = $AccessToken

496 -

'TelemetryEventName' = $MyInvocation.MyCommand.Name

497 -

'TelemetryProperties' = $telemetryProperties

498 -

'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue `

499 -

-Name NoStatus -ConfigValueName DefaultNoStatus)

500 -

}

485 +

return

486 +

}

501 487 502 -

Invoke-GHRestMethod @params | Out-Null

488 +

$params = @{

489 +

'UriFragment' = $uriFragment

490 +

'Method' = 'Delete'

491 +

'Description' = "Deleting branch $BranchName from $RepositoryName"

492 +

'AccessToken' = $AccessToken

493 +

'TelemetryEventName' = $MyInvocation.MyCommand.Name

494 +

'TelemetryProperties' = $telemetryProperties

495 +

'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue `

496 +

-Name NoStatus -ConfigValueName DefaultNoStatus)

503 497

}

498 + 499 +

Invoke-GHRestMethod @params | Out-Null

504 500

}

505 501 506 502

filter Get-GitHubRepositoryBranchProtectionRule

@@ -965,27 +961,29 @@ filter New-GitHubRepositoryBranchProtectionRule

965 961

$hashBody['allow_deletions'] = $AllowDeletions.ToBool()

966 962

}

967 963 968 -

if ($PSCmdlet.ShouldProcess(

964 +

if (-not $PSCmdlet.ShouldProcess(

969 965

"'$BranchName' branch of repository '$RepositoryName'",

970 966

'Create GitHub Repository Branch Protection Rule'))

971 967

{

972 -

$jsonConversionDepth = 3

973 - 974 -

$params = @{

975 -

UriFragment = "repos/$OwnerName/$RepositoryName/branches/$BranchName/protection"

976 -

Body = (ConvertTo-Json -InputObject $hashBody -Depth $jsonConversionDepth)

977 -

Description = "Setting $BranchName branch protection status for $RepositoryName"

978 -

Method = 'Put'

979 -

AcceptHeader = $script:lukeCageAcceptHeader

980 -

AccessToken = $AccessToken

981 -

TelemetryEventName = $MyInvocation.MyCommand.Name

982 -

TelemetryProperties = $telemetryProperties

983 -

NoStatus = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus `

984 -

-ConfigValueName DefaultNoStatus)

985 -

}

968 +

return

969 +

}

970 + 971 +

$jsonConversionDepth = 3

986 972 987 -

return (Invoke-GHRestMethod @params | Add-GitHubBranchProtectionRuleAdditionalProperties)

973 +

$params = @{

974 +

UriFragment = "repos/$OwnerName/$RepositoryName/branches/$BranchName/protection"

975 +

Body = (ConvertTo-Json -InputObject $hashBody -Depth $jsonConversionDepth)

976 +

Description = "Setting $BranchName branch protection status for $RepositoryName"

977 +

Method = 'Put'

978 +

AcceptHeader = $script:lukeCageAcceptHeader

979 +

AccessToken = $AccessToken

980 +

TelemetryEventName = $MyInvocation.MyCommand.Name

981 +

TelemetryProperties = $telemetryProperties

982 +

NoStatus = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus `

983 +

-ConfigValueName DefaultNoStatus)

988 984

}

985 + 986 +

return (Invoke-GHRestMethod @params | Add-GitHubBranchProtectionRuleAdditionalProperties)

989 987

}

990 988 991 989

filter Remove-GitHubRepositoryBranchProtectionRule

@@ -1100,23 +1098,25 @@ filter Remove-GitHubRepositoryBranchProtectionRule

1100 1098

$ConfirmPreference = 'None'

1101 1099

}

1102 1100 1103 -

if ($PSCmdlet.ShouldProcess("'$BranchName' branch of repository '$RepositoryName'",

1101 +

if (-not $PSCmdlet.ShouldProcess("'$BranchName' branch of repository '$RepositoryName'",

1104 1102

'Remove GitHub Repository Branch Protection Rule'))

1105 1103

{

1106 -

$params = @{

1107 -

UriFragment = "repos/$OwnerName/$RepositoryName/branches/$BranchName/protection"

1108 -

Description = "Removing $BranchName branch protection rule for $RepositoryName"

1109 -

Method = 'Delete'

1110 -

AcceptHeader = $script:lukeCageAcceptHeader

1111 -

AccessToken = $AccessToken

1112 -

TelemetryEventName = $MyInvocation.MyCommand.Name

1113 -

TelemetryProperties = $telemetryProperties

1114 -

NoStatus = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus `

1115 -

-ConfigValueName DefaultNoStatus)

1116 -

}

1104 +

return

1105 +

}

1117 1106 1118 -

return Invoke-GHRestMethod @params | Out-Null

1107 +

$params = @{

1108 +

UriFragment = "repos/$OwnerName/$RepositoryName/branches/$BranchName/protection"

1109 +

Description = "Removing $BranchName branch protection rule for $RepositoryName"

1110 +

Method = 'Delete'

1111 +

AcceptHeader = $script:lukeCageAcceptHeader

1112 +

AccessToken = $AccessToken

1113 +

TelemetryEventName = $MyInvocation.MyCommand.Name

1114 +

TelemetryProperties = $telemetryProperties

1115 +

NoStatus = (Resolve-ParameterWithDefaultConfigurationValue -Name NoStatus `

1116 +

-ConfigValueName DefaultNoStatus)

1119 1117

}

1118 + 1119 +

return Invoke-GHRestMethod @params | Out-Null

1120 1120

}

1121 1121 1122 1122

filter Add-GitHubBranchAdditionalProperties


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4