github

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package github 封装 release-note 流程使用的 GitHub REST 读写边界。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidRepository

func ValidRepository(repository string) bool

ValidRepository 判断 owner/name 形式的 GitHub 仓库标识。

Types

type Client

type Client struct {
	BaseURL    string
	Token      string
	HTTPClient *http.Client
}

Client 是 release-note 流程使用的 GitHub HTTP 客户端。 Token 只用于请求头,不会被错误信息或报告序列化。

func New

func New(baseURL, token string, httpClient *http.Client) Client

New 构造 GitHub 客户端;nil HTTP client 保持由 requestJSON 使用默认客户端。

func (Client) GetJSON

func (client Client) GetJSON(ctx context.Context, path string, destination any) error

GetJSON 执行 GitHub REST GET 请求。

func (Client) PullRequest

func (client Client) PullRequest(ctx context.Context, repository string, number int) (model.GitHubPullRequest, error)

PullRequest 读取指定 PR 的完整信息。

func (Client) PullRequestsForCommit

func (client Client) PullRequestsForCommit(ctx context.Context, repository, commit string) ([]model.GitHubPullRequest, error)

PullRequestsForCommit 查询一个 commit 关联的 PR。

func (Client) RequestJSON

func (client Client) RequestJSON(ctx context.Context, method, path string, input, destination any) error

RequestJSON 执行 GitHub REST JSON 请求。

type HTTPError

type HTTPError struct {
	Path       string
	StatusCode int
	Body       string
}

HTTPError 保留 GitHub 非 2xx 响应的路径、状态码和正文摘要。

func (*HTTPError) Error

func (err *HTTPError) Error() string

Jump to

Keyboard shortcuts

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