Skip to content

Commit d1bd976

Browse files
authored
Set-GitHubRepositoryTopic: Fix Exception When Clear 'Parameter' is Specified (#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
1 parent 00f099f commit d1bd976

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

GitHubRepositories.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,12 +1033,18 @@ function Set-GitHubRepositoryTopic
10331033
'Clear' = $PSBoundParameters.ContainsKey('Clear')
10341034
}
10351035

1036-
$description = "Replacing topics in $RepositoryName"
1037-
if ($Clear) { $description = "Clearing topics in $RepositoryName" }
1036+
if ($Clear)
1037+
{
1038+
$description = "Clearing topics in $RepositoryName"
1039+
$Name = @()
1040+
}
1041+
else
1042+
{
1043+
$description = "Replacing topics in $RepositoryName"
1044+
}
10381045

1039-
$names = @($Name)
10401046
$hashBody = @{
1041-
'names' = $names
1047+
'names' = $Name
10421048
}
10431049

10441050
$params = @{

0 commit comments

Comments
 (0)