-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Summary
Implement label management functionality in the GitHub module covering the full set of REST API endpoints for labels.
Currently, there are no label-related functions, classes, or types in the module.
Design
Following the existing module patterns (like Get-GitHubTeam, Get-GitHubReleaseAsset, Remove-GitHubSecret), the label functionality is consolidated into fewer public functions that route to private helpers via parameter sets.
Public Functions
Get-GitHubLabel
Consolidated getter following the Get-GitHubTeam / Get-GitHubReleaseAsset pattern with parameter sets:
| ParameterSet | Trigger | API Endpoint | Private Function |
|---|---|---|---|
Repository (default) |
-Owner -Repository |
GET /repos/{owner}/{repo}/labels |
Get-GitHubLabelListByRepo |
ByName |
-Name |
GET /repos/{owner}/{repo}/labels/{name} |
Get-GitHubLabelByName |
Issue |
-Issue (alias: -PullRequest, -PR) |
GET /repos/{owner}/{repo}/issues/{issue_number}/labels |
Get-GitHubLabelListByIssue |
Milestone |
-Milestone |
GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels |
Get-GitHubLabelListByMilestone |
New-GitHubLabel
Creates a new label on a repository. Single parameter set.
| API Endpoint | Parameters |
|---|---|
POST /repos/{owner}/{repo}/labels |
-Owner, -Repository, -Name, -Color, -Description |
Update-GitHubLabel
Updates an existing label on a repository. Single parameter set.
| API Endpoint | Parameters |
|---|---|
PATCH /repos/{owner}/{repo}/labels/{name} |
-Owner, -Repository, -Name, -NewName, -Color, -Description |
Set-GitHubLabel
Upsert for repo labels (like Set-GitHubVariable: calls Get then New or Update).
| API Endpoint | Parameters |
|---|---|
POST or PATCH /repos/{owner}/{repo}/labels/{name} |
-Owner, -Repository, -Name, -Color, -Description |
Add-GitHubIssueLabel
Adds label(s) to an issue without removing existing labels. Follows the Add-GitHubReleaseAsset / Add-GitHubVariableSelectedRepository pattern for associating resources.
| API Endpoint | Parameters |
|---|---|
POST /repos/{owner}/{repo}/issues/{issue_number}/labels |
-Owner, -Repository, -Issue (alias: -PullRequest, -PR), -Labels |
Set-GitHubIssueLabel
Replaces all labels on an issue (PUT = replace semantics). This is a distinct operation from Set-GitHubLabel (upsert) — it sets the complete label list on an issue.
| API Endpoint | Parameters |
|---|---|
PUT /repos/{owner}/{repo}/issues/{issue_number}/labels |
-Owner, -Repository, -Issue (alias: -PullRequest, -PR), -Labels |
Remove-GitHubLabel
Deletes a label from a repository.
| API Endpoint | Parameters |
|---|---|
DELETE /repos/{owner}/{repo}/labels/{name} |
-Owner, -Repository, -Name |
Uses ConfirmImpact = 'High' and ShouldProcess.
Remove-GitHubIssueLabel
Removes label(s) from an issue. Two parameter sets following the Remove-GitHubSecret scope-routing pattern:
| ParameterSet | Trigger | API Endpoint | Private Function |
|---|---|---|---|
ByName |
-Name |
DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name} |
Remove-GitHubLabelFromIssue |
All |
(no -Name) |
DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels |
Remove-GitHubLabelFromIssueAll |
Private Functions (one per API endpoint)
src/functions/private/Labels/
Get-GitHubLabelListByRepo.ps1 # GET /repos/{o}/{r}/labels
Get-GitHubLabelByName.ps1 # GET /repos/{o}/{r}/labels/{name}
Get-GitHubLabelListByIssue.ps1 # GET /repos/{o}/{r}/issues/{n}/labels
Get-GitHubLabelListByMilestone.ps1 # GET /repos/{o}/{r}/milestones/{n}/labels
New-GitHubLabelOnRepository.ps1 # POST /repos/{o}/{r}/labels
Update-GitHubLabelOnRepository.ps1 # PATCH /repos/{o}/{r}/labels/{name}
Remove-GitHubLabelFromRepository.ps1 # DELETE /repos/{o}/{r}/labels/{name}
Add-GitHubLabelToIssue.ps1 # POST /repos/{o}/{r}/issues/{n}/labels
Set-GitHubLabelOnIssue.ps1 # PUT /repos/{o}/{r}/issues/{n}/labels
Remove-GitHubLabelFromIssue.ps1 # DELETE /repos/{o}/{r}/issues/{n}/labels/{name}
Remove-GitHubLabelFromIssueAll.ps1 # DELETE /repos/{o}/{r}/issues/{n}/labels
File Structure
src/
classes/public/
GitHubLabel.ps1
formats/
GitHubLabel.Format.ps1xml
types/
GitHubLabel.Types.ps1xml
functions/
public/Labels/
Get-GitHubLabel.ps1
New-GitHubLabel.ps1
Update-GitHubLabel.ps1
Set-GitHubLabel.ps1
Remove-GitHubLabel.ps1
Add-GitHubIssueLabel.ps1
Set-GitHubIssueLabel.ps1
Remove-GitHubIssueLabel.ps1
private/Labels/
Get-GitHubLabelListByRepo.ps1
Get-GitHubLabelByName.ps1
Get-GitHubLabelListByIssue.ps1
Get-GitHubLabelListByMilestone.ps1
New-GitHubLabelOnRepository.ps1
Update-GitHubLabelOnRepository.ps1
Remove-GitHubLabelFromRepository.ps1
Add-GitHubLabelToIssue.ps1
Set-GitHubLabelOnIssue.ps1
Remove-GitHubLabelFromIssue.ps1
Remove-GitHubLabelFromIssueAll.ps1
Implementation Checklist
Classes and Types
- Create
GitHubLabelclass insrc/classes/public/ - Create
GitHubLabel.Types.ps1xmlinsrc/types/ - Create
GitHubLabel.Format.ps1xmlinsrc/formats/
Public Functions
-
Get-GitHubLabel— List repo labels / get by name / list by issue / list by milestone (parameter sets) -
New-GitHubLabel— Create a repo label -
Update-GitHubLabel— Update a repo label -
Set-GitHubLabel— Upsert a repo label (Get → New or Update) -
Add-GitHubIssueLabel— Add labels to an issue -
Set-GitHubIssueLabel— Replace all labels on an issue -
Remove-GitHubLabel— Delete a repo label -
Remove-GitHubIssueLabel— Remove a label / all labels from an issue (parameter sets)
Private Functions
-
Get-GitHubLabelListByRepo—GET /repos/{o}/{r}/labels -
Get-GitHubLabelByName—GET /repos/{o}/{r}/labels/{name} -
Get-GitHubLabelListByIssue—GET /repos/{o}/{r}/issues/{n}/labels -
Get-GitHubLabelListByMilestone—GET /repos/{o}/{r}/milestones/{n}/labels -
New-GitHubLabelOnRepository—POST /repos/{o}/{r}/labels -
Update-GitHubLabelOnRepository—PATCH /repos/{o}/{r}/labels/{name} -
Remove-GitHubLabelFromRepository—DELETE /repos/{o}/{r}/labels/{name} -
Add-GitHubLabelToIssue—POST /repos/{o}/{r}/issues/{n}/labels -
Set-GitHubLabelOnIssue—PUT /repos/{o}/{r}/issues/{n}/labels -
Remove-GitHubLabelFromIssue—DELETE /repos/{o}/{r}/issues/{n}/labels/{name} -
Remove-GitHubLabelFromIssueAll—DELETE /repos/{o}/{r}/issues/{n}/labels
Completers
- Add tab-completion for label names
Tests
- Integration tests for all label functions
Label Object Properties
Based on the API response schema:
| Property | Type | Description |
|---|---|---|
id |
integer | Label ID |
node_id |
string | Node ID |
url |
string | API URL |
name |
string | Label name |
description |
string | Label description |
color |
string | Hex color code (without #) |
default |
boolean | Whether this is a default label |
Design Rationale
Consolidation into Get-GitHubLabel
Instead of separate Get-GitHubIssueLabel and Get-GitHubMilestoneLabel public functions, the -Issue and -Milestone parameters on Get-GitHubLabel route to private helpers — matching the Get-GitHubTeam pattern where -Repository and -Slug select different retrieval modes.
The -Issue parameter uses aliases -PullRequest and -PR since every PR is an issue in GitHub's API.
Issue Label Operations Stay Separate
Add-GitHubIssueLabel, Set-GitHubIssueLabel, and Remove-GitHubIssueLabel remain separate public functions because they operate on a different resource relationship (issue↔label association) than New-GitHubLabel / Update-GitHubLabel / Remove-GitHubLabel (repo label CRUD). Mixing these into the same function would create confusing parameter sets.
This follows the established pattern: Add-GitHubReleaseAsset is separate from New-GitHubRelease, and Add-GitHubSecretSelectedRepository is separate from Set-GitHubSecret.
References
Metadata
Metadata
Labels
Type
Projects
Status