github

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github provides utilities for working with GitHub URLs and the GitHub API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBlobURL

func IsBlobURL(url string) bool

IsBlobURL checks if a URL is a GitHub blob URL (single file).

func IsGitHubURL

func IsGitHubURL(url string) bool

IsGitHubURL checks if a URL is any kind of GitHub URL we can handle.

func IsTreeURL

func IsTreeURL(url string) bool

IsTreeURL checks if a URL is a GitHub tree URL (directory).

Types

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher handles downloading files and directories from GitHub.

func NewFetcher

func NewFetcher() *Fetcher

NewFetcher creates a new GitHub fetcher.

func (*Fetcher) FetchDirectory

func (f *Fetcher) FetchDirectory(ctx context.Context, treeURL *TreeURL) ([]byte, error)

FetchDirectory downloads all files from a GitHub directory and returns them as a zip.

func (*Fetcher) WithToken

func (f *Fetcher) WithToken(token string) *Fetcher

WithToken sets an optional GitHub token for authenticated requests. This increases rate limits from 60/hour to 5000/hour.

type TreeURL

type TreeURL struct {
	Owner string // Repository owner (e.g., "metabase")
	Repo  string // Repository name (e.g., "metabase")
	Ref   string // Branch, tag, or commit (e.g., "master")
	Path  string // Path within the repository (e.g., ".claude/skills/docs-write")
}

TreeURL represents a parsed GitHub tree URL pointing to a directory. Example: https://github.com/metabase/metabase/tree/master/.claude/skills/docs-write

func ParseTreeURL

func ParseTreeURL(url string) *TreeURL

ParseTreeURL parses a GitHub tree URL into its components. Returns nil if the URL is not a valid GitHub tree URL.

func (*TreeURL) ContentsAPIURL

func (t *TreeURL) ContentsAPIURL() string

ContentsAPIURL returns the GitHub API URL for listing directory contents. Example: https://api.github.com/repos/metabase/metabase/contents/.claude/skills/docs-write?ref=master

func (*TreeURL) RawURL

func (t *TreeURL) RawURL(filename string) string

RawURL returns the raw.githubusercontent.com URL for a file within this tree. Example: https://raw.githubusercontent.com/metabase/metabase/master/.claude/skills/docs-write/SKILL.md

func (*TreeURL) SkillName

func (t *TreeURL) SkillName() string

SkillName returns a suggested name for the skill based on the path. Uses the last component of the path, or repo name if path is empty.

func (*TreeURL) String

func (t *TreeURL) String() string

String returns the original GitHub tree URL.

Jump to

Keyboard shortcuts

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