Skip to content

Commit

Permalink
Set-GitHubRepositoryTopic: Fix Exception When Clear 'Parameter' is Sp…
Browse files Browse the repository at this point in the history
…ecified (#216)

This fixes the exception in the `Set-GithubRepositoryTopic` function when the `Clear` parameter is specified.

#### References
https://developer.github.com/v3/repos/#replace-all-repository-topics - Send an empty array ([]) to clear all topics from the repository.

The problem with the existing implementation was that it was creating an array of 1 element, where the element was `$null`.

Fixes #215
  • Loading branch information
X-Guardian authored Jun 2, 2020
1 parent 00f099f commit d1bd976
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions GitHubRepositories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1033,12 +1033,18 @@ function Set-GitHubRepositoryTopic
'Clear' = $PSBoundParameters.ContainsKey('Clear')
}

$description = "Replacing topics in $RepositoryName"
if ($Clear) { $description = "Clearing topics in $RepositoryName" }
if ($Clear)
{
$description = "Clearing topics in $RepositoryName"
$Name = @()
}
else
{
$description = "Replacing topics in $RepositoryName"
}

$names = @($Name)
$hashBody = @{
'names' = $names
'names' = $Name
}

$params = @{
Expand Down

0 comments on commit d1bd976

Please sign in to comment.