repoutil

package
v0.82.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 3 Imported by: 0

README

repoutil Package

The repoutil package provides utility functions for working with GitHub repository slugs.

Overview

This package offers focused helpers for parsing and normalizing repository identifiers, which are used throughout the codebase wherever GitHub repositories are referenced.

Public API

Functions
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

Usage Examples

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"

Dependencies

Internal:

  • github.com/github/gh-aw/pkg/logger — debug logging

Design Notes

  • All debug output uses logger.New("repoutil:repoutil") and is only emitted when DEBUG=repoutil:*.
  • For paths that include sub-folders (e.g. GitHub Actions uses: fields such as github/codeql-action/upload-sarif), use gitutil.ExtractBaseRepo first to strip the sub-path before calling SplitRepoSlug.

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package repoutil provides utility functions for working with GitHub repository slugs and URLs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeRepoForAPI added in v0.82.0

func NormalizeRepoForAPI(repo string) (ownerRepo string, host string)

NormalizeRepoForAPI splits a repo string of the form "[HOST/]owner/repo" into the owner/repo portion and an optional host. Most callers pass plain "owner/repo", but GHES and Proxima installs may supply "HOST/owner/repo".

func SplitRepoSlug

func SplitRepoSlug(slug string) (owner, repo string, err error)

SplitRepoSlug splits a repository slug (owner/repo) into owner and repo parts. Returns an error if the slug format is invalid.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL