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

Bug in Update-GitHubRepository Archived parameter usage #134

Closed
amis92 opened this issue Sep 24, 2019 · 2 comments · Fixed by #135
Closed

Bug in Update-GitHubRepository Archived parameter usage #134

amis92 opened this issue Sep 24, 2019 · 2 comments · Fixed by #135
Labels
bug This relates to a bug in the existing module.

Comments

@amis92
Copy link

amis92 commented Sep 24, 2019

So I'm pretty sure there's a bug in Update-GitHubRepository cmdlet - found it by just browsing source code:

if ($PSBoundParameters.ContainsKey('Archived')) { $hashBody['archived'] = (-not $Archived.ToBool()) }

Passing the Archived switch will result in archived=false parameter passed to API.

Is:
$hashBody['archived'] = (-not $Archived.ToBool())
Should be:
$hashBody['archived'] = $Archived.ToBool()

This is probably a copy-paste error since all other properties use inverted style:

if ($PSBoundParameters.ContainsKey('DisallowSquashMerge')) { $hashBody['allow_squash_merge'] = (-not $DisallowSquashMerge.ToBool()) }
if ($PSBoundParameters.ContainsKey('DisallowMergeCommit')) { $hashBody['allow_merge_commit'] = (-not $DisallowMergeCommit.ToBool()) }
if ($PSBoundParameters.ContainsKey('DisallowRebaseMerge')) { $hashBody['allow_rebase_merge'] = (-not $DisallowRebaseMerge.ToBool()) }
if ($PSBoundParameters.ContainsKey('Archived')) { $hashBody['archived'] = (-not $Archived.ToBool()) }

@HowardWolosky HowardWolosky added the bug This relates to a bug in the existing module. label Sep 24, 2019
HowardWolosky added a commit to HowardWolosky/PowerShellForGitHub that referenced this issue Sep 24, 2019
Due to a copy-paste error, the function was incorrectly inverting the
user's choice.

A separate work item will be created to track adding some additional
tests to this part of the code.

Fixes microsoft#134
HowardWolosky added a commit that referenced this issue Sep 24, 2019
…135)

Due to a copy-paste error, the function was incorrectly inverting the
user's choice.

A separate work item will be created to track adding some additional
tests to this part of the code.

Fixes #134
@HowardWolosky
Copy link
Member

Wow....great catch @amis92! Thanks so much for pointing that out and opening the Issue to let us know. What inspired you to do code inspection like this?

@amis92
Copy link
Author

amis92 commented Sep 24, 2019

Well I'm writing an automation script and whenever I can I check the code I depend on, but also I guess a lucky catch. :)

smaglio81 pushed a commit to ucsb/ucsb-sa-enterprise-powershellforgithub that referenced this issue Sep 25, 2019
…icrosoft#135)

Due to a copy-paste error, the function was incorrectly inverting the
user's choice.

A separate work item will be created to track adding some additional
tests to this part of the code.

Fixes microsoft#134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This relates to a bug in the existing module.
Projects
None yet
2 participants