ghorg

package
v0.169.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ghorg reads files and organisation lists through the GitHub REST API with a reserve that latches: the one client behind `orgfile` and `orgedit`.

GitHub code search is blind to the files these commands target, so a file is read through the contents endpoint, one call each, and the remaining quota is read off every response.

Index

Constants

View Source
const MaxBody = 4 << 20

MaxBody bounds a file read: a runner config is a few KB.

Variables

View Source
var NameRe = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)

NameRe matches a GitHub owner or repository name.

Functions

func EscapePath

func EscapePath(p string) string

EscapePath escapes each segment of a path for a URL.

func Logins

func Logins(b []byte) ([]string, error)

Logins decodes the organisation names of one /user/orgs page.

func ValidName

func ValidName(n string) bool

ValidName reports whether n is a usable GitHub name.

func ValidPath

func ValidPath(p string) bool

ValidPath reports whether p is a bounded relative path with no empty, "." or ".." segment.

Types

type Client

type Client struct {
	Base, Token string
	HTTP        *http.Client
	Reserve     int
	// contains filtered or unexported fields
}

Client counts nothing itself: it reads the reserve off every response.

func New

func New(base, token string, reserve int) *Client

New builds a client for base (an API root) with a bearer token.

func (*Client) Calls

func (c *Client) Calls() int

Calls is the number of responses received.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, raw bool) (int, []byte, error)

Get returns the status and body of one GET. raw asks for the file's bytes.

func (*Client) Low

func (c *Client) Low() bool

Low reports whether the reserve is reached, latching the stop.

func (*Client) Orgs

func (c *Client) Orgs(ctx context.Context) ([]string, error)

Orgs lists every organisation of the account, page by page, sorted.

func (*Client) Remaining

func (c *Client) Remaining() int

Remaining is the last quota a response reported, or -1.

func (*Client) Stopped

func (c *Client) Stopped() bool

Stopped reports whether the reserve was ever reached.

Jump to

Keyboard shortcuts

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