adapter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 9 Imported by: ? 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

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type Client

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

func New

func New(domain string) *Client

func (*Client) AddComment

func (c *Client) AddComment(ctx context.Context, token, owner, name string, issueNumber int, body string) (Comment, error)

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, token, owner, name, title, body string, labels, assignees []string) (Issue, error)

func (*Client) CreatePR

func (c *Client) CreatePR(ctx context.Context, token, owner, name, title, body, head, base string, draft bool) (PullRequest, error)

func (*Client) GetBlob

func (c *Client) GetBlob(ctx context.Context, token, owner, name, sha string) ([]byte, error)

GetBlob fetches blob content by SHA via the Git Data API.

func (*Client) GetCommitTreeSHA

func (c *Client) GetCommitTreeSHA(ctx context.Context, token, owner, name, ref string) (string, error)

GetCommitTreeSHA resolves a ref (branch/tag/commit) to its tree SHA via commits API.

func (*Client) GetFileContent

func (c *Client) GetFileContent(ctx context.Context, token, owner, name, path, ref string) ([]byte, error)

GetFileContent fetches raw file bytes via the contents API.

func (*Client) GetRepoDefaultBranch

func (c *Client) GetRepoDefaultBranch(ctx context.Context, token, owner, name string) (string, error)

GetRepoDefaultBranch returns the default branch name (e.g., "main" or "master").

func (*Client) GetTreeRecursive

func (c *Client) GetTreeRecursive(ctx context.Context, token, owner, name, treeSha string) ([]TreeEntry, bool, error)

GetTreeRecursive fetches a full tree listing with recursive=1. Returns entries and whether it was truncated.

func (*Client) ListComments

func (c *Client) ListComments(ctx context.Context, token, owner, name string, issueNumber int) ([]Comment, error)

func (*Client) ListContents

func (c *Client) ListContents(ctx context.Context, token, owner, name, path, ref string) ([]ContentItem, error)

ListContents lists directory entries at path, or returns a single item if path points to a file.

func (*Client) ListRepoIssues

func (c *Client) ListRepoIssues(ctx context.Context, token, owner, name, state string) ([]Issue, error)

func (*Client) ListRepoPRs

func (c *Client) ListRepoPRs(ctx context.Context, token, owner, name, state string) ([]PullRequest, error)

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context, token, visibility, affiliation string, perPage int) ([]Repo, error)

func (*Client) SearchIssues

func (c *Client) SearchIssues(ctx context.Context, token, query string, perPage int) ([]Issue, error)

func (*Client) ValidateRef

func (c *Client) ValidateRef(ctx context.Context, token, owner, name, ref string) error

ValidateRef checks whether a ref (branch/tag/sha) is usable with the Contents API by probing the repository root contents with the supplied ref. It returns nil on any 2xx response, ErrUnauthorized on 401, and an error otherwise.

func (*Client) ValidateToken

func (c *Client) ValidateToken(ctx context.Context, token string) error

ValidateToken performs a lightweight call to verify that provided credentials are valid. It calls the /user endpoint which requires an authenticated token.

type Comment

type Comment struct {
	ID                    int64
	Body, User, CreatedAt string
}

type ContentItem

type ContentItem struct {
	Type        string `json:"type"` // "file" or "dir"
	Name        string `json:"name"`
	Path        string `json:"path"`
	Sha         string `json:"sha"`
	Size        int    `json:"size"`
	DownloadURL string `json:"download_url"`
}

ContentItem represents a file or directory in the repo contents API.

type Issue

type Issue struct {
	ID           int64
	Number       int
	Title, State string
}

type PullRequest

type PullRequest struct {
	ID           int64
	Number       int
	Title, State string
}

type Repo

type Repo struct {
	ID             int64
	Name, FullName string
}

type TreeEntry

type TreeEntry struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
	Type string `json:"type"` // "blob" | "tree" | "commit" (submodule)
	Size int    `json:"size,omitempty"`
	Sha  string `json:"sha"`
	Url  string `json:"url"`
}

Trees API types

Jump to

Keyboard shortcuts

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