The repoutil package provides utility functions for working with GitHub repository slugs.
This package offers focused helpers for parsing and normalizing repository identifiers, which are used throughout the codebase wherever GitHub repositories are referenced.
| Function | Signature | Description |
|---|---|---|
SplitRepoSlug |
func(slug string) (owner, repo string, err error) |
Splits a repository slug of the form owner/repo into its two components; returns an error when the slug does not contain exactly one / or when either component is empty |
NormalizeRepoForAPI |
func(repo string) (ownerRepo string, host string) |
Splits a repository string of the form [HOST/]owner/repo into the owner/repo portion and an optional host name for GHES/Proxima API calls |
import "github.com/github/gh-aw/pkg/repoutil"
owner, repo, err := repoutil.SplitRepoSlug("github/gh-aw")
if err != nil {
return fmt.Errorf("invalid repository: %w", err)
}
// owner = "github", repo = "gh-aw"Internal:
github.com/github/gh-aw/pkg/logger— debug logging
- All debug output uses
logger.New("repoutil:repoutil")and is only emitted whenDEBUG=repoutil:*. - For paths that include sub-folders (e.g. GitHub Actions
uses:fields such asgithub/codeql-action/upload-sarif), usegitutil.ExtractBaseRepofirst to strip the sub-path before callingSplitRepoSlug. NormalizeRepoForAPIonly treats three-segment strings asHOST/owner/repo; plainowner/repovalues are returned unchanged with an empty host.
This specification is automatically maintained by the spec-extractor workflow.