github

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRepo

func ParseRepo(input string) (owner, repo string, err error)

ParseRepo parses "owner/repo", "https://github.com/owner/repo", or "https://github.com/owner/repo/..." into (owner, repo) strings. Returns error if format is unrecognized.

Types

type Contributor

type Contributor struct {
	Login         string // GitHub username
	HTMLURL       string // profile URL
	AvatarURL     string // avatar URL
	Contributions int    // commit count — used directly as proportional weight
}

Contributor holds a GitHub contributor with commit count.

func FetchContributors

func FetchContributors(ctx context.Context, owner, repo, token string) ([]Contributor, error)

FetchContributors fetches contributors from GET https://api.github.com/repos/{owner}/{repo}/contributors. Paginates (100 per page) until all contributors are fetched. token is optional.

type RepoInfo

type RepoInfo struct {
	Owner       string   // e.g. "GainForest"
	Name        string   // e.g. "hypercerts-cli"
	FullName    string   // e.g. "GainForest/hypercerts-cli"
	Description string   // repo description
	HTMLURL     string   // e.g. "https://github.com/GainForest/hypercerts-cli"
	CreatedAt   string   // RFC3339 timestamp
	PushedAt    string   // RFC3339 timestamp
	Language    string   // primary language
	Topics      []string // repo topics
	License     string   // SPDX ID (e.g. "MIT"), empty if none
	AvatarURL   string   // owner avatar URL
}

RepoInfo holds parsed GitHub repo metadata.

func FetchRepo

func FetchRepo(ctx context.Context, owner, repo, token string) (*RepoInfo, error)

FetchRepo fetches repo metadata from GET https://api.github.com/repos/{owner}/{repo}. token is optional (empty string = unauthenticated). Returns error on non-200 status (include status code in error message).

Jump to

Keyboard shortcuts

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