Skip to content

Add repository-level custom property value management and integration tests #588

@MariusStorhaug

Description

Repository owners and automation workflows need to read and set custom property values on individual repositories. While property definitions are managed at the organization or enterprise level, values can be set at the repository level by repo admins or users with the edit custom property values permission. The module currently has Get-GitHubRepositoryCustomProperty but lacks the ability to set values, and the existing function needs integration tests.

Request

Desired capability

Complete repository-level custom property value management: get and set property values on individual repositories. The Get- function already exists but needs proper integration tests that own their lifecycle (create definitions at org level, set values, read back, validate types including multi-select array preservation, clean up). A Set- function is needed to assign or unset values.

Acceptance criteria

  • Set-GitHubRepositoryCustomProperty is implemented to create/update values on a single repo
  • Unsetting a property (setting value to null) is supported
  • All five value types work correctly: string, single_select, multi_select, true_false, url
  • Multi-select values are preserved as [string[]] arrays (the fix from 🪲 [Fix]: Multi-select custom properties no longer lose individual values #577)
  • Integration tests own their full lifecycle: create org-level definitions → set values on repo → read back → validate → update → unset → clean up definitions
  • Tests cover all five value types including multi-select array preservation
  • The existing Get-GitHubRepositoryCustomProperty function has proper test coverage

Technical decisions

API choice: REST API. The repository custom properties endpoints provide get and set for values.

Endpoints:

Method Endpoint Function Status
GET /repos/{owner}/{repo}/properties/values Get-GitHubRepositoryCustomProperty Exists — needs tests
PATCH /repos/{owner}/{repo}/properties/values Set-GitHubRepositoryCustomProperty New

Permissions required:

  • Read: "Metadata" repository permissions (read) — works unauthenticated for public repos
  • Write: "Custom properties" repository permissions (write)

Function placement:

  • Public: src/functions/public/Repositories/CustomProperties/

Set payload:

{
  "properties": [
    { "property_name": "environment", "value": "production" },
    { "property_name": "topics", "value": ["api", "module", "automation"] },
    { "property_name": "archived", "value": null }
  ]
}

Setting value to null unsets (removes) the property from the repository.

Dependency on org-level definitions: Property values can only be set if the corresponding definition exists at the organization (or enterprise) level. Tests must first create definitions using the org-level functions from #587, then set and read values.

Class: The existing GitHubCustomProperty class handles the value response correctly (including multi-select array preservation from #577). No class changes needed.

Test approach: Integration tests in tests/Repositories.Tests.ps1 within the organization context (-Skip:($OwnerType -ne 'organization')). Tests require org-level property definitions as prerequisites, so they should:

  1. Create org-level property definitions in BeforeAll (one of each type)
  2. Set values on the test repository
  3. Read back values using Get-GitHubRepositoryCustomProperty
  4. Validate types (especially multi-select as [string[]])
  5. Update values
  6. Unset values using null
  7. Remove org-level definitions in AfterAll

Note

This issue depends on #587 (Organization Custom Properties) for the org-level definition management functions used in test setup/cleanup. If #587 is not yet implemented, the test setup can use raw Invoke-GitHubAPI calls temporarily.


Implementation plan

Public functions

  • Set-GitHubRepositoryCustomProperty — create/update/unset values on a single repo (src/functions/public/Repositories/CustomProperties/)

Tests

  • Add repo custom property lifecycle test in tests/Repositories.Tests.ps1 (org context only)
  • BeforeAll: Create org-level property definitions (one of each type: string, single_select, multi_select, true_false, url)
  • Test Set-GitHubRepositoryCustomProperty — set string value, read back
  • Test Set-GitHubRepositoryCustomProperty — set single_select value, read back
  • Test Set-GitHubRepositoryCustomProperty — set multi_select value (array), read back, verify [string[]] type
  • Test Set-GitHubRepositoryCustomProperty — set true_false value, read back
  • Test Set-GitHubRepositoryCustomProperty — set url value, read back
  • Test Set-GitHubRepositoryCustomProperty — unset value with $null, verify removed
  • Test Get-GitHubRepositoryCustomProperty — validates all returned properties have correct Name and typed Value
  • Test Get-GitHubRepository .CustomProperties property — verify it populates from both REST and GraphQL paths
  • AfterAll: Remove org-level property definitions

Cleanup from #577

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions