github

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentHost = "https://raw.githubusercontent.com"
	// ContentURLTpl eg: https://raw.githubusercontent.com/gookit/slog/master/README.md
	ContentURLTpl = "https://raw.githubusercontent.com/%s/%s/%s"
)

Variables

This section is empty.

Functions

func ContentURL

func ContentURL(repoPath, branch, filePath string) string

ContentURL for GitHub repo file

Types

type CommitAuthor

type CommitAuthor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Date  string `json:"date"`
}

CommitAuthor info from commit payload.

type CommitDetail

type CommitDetail struct {
	Author  CommitAuthor `json:"author"`
	Message string       `json:"message"`
}

CommitDetail info from commit payload.

type CommitInfo

type CommitInfo struct {
	SHA     string       `json:"sha"`
	HTMLURL string       `json:"html_url"`
	Commit  CommitDetail `json:"commit"`
}

CommitInfo represents a github commit item.

type GitHub

type GitHub struct {
	*gitx.Config

	// GitHub 文件, Releases, archive, gist, raw.githubusercontent.com 文件代理加速下载服务.
	// eg: https://ghproxy.com
	ProxyHost string `json:"proxy_host"`
	// Username on https://github.com
	Username string `json:"username"`
	// Token person token.
	Token string `json:"token"`
	// BaseApi api url
	BaseApi string `json:"base_api"`
}

GitHub config struct

func New

func New(cfg *gitx.Config) *GitHub

New config instance

func (*GitHub) CreateAnnotatedTag

func (g *GitHub) CreateAnnotatedTag(in TagCreateInput) (*TagCreateResponse, error)

CreateAnnotatedTag creates annotated tag and tag ref by GitHub Git Database API.

func (*GitHub) GetLatestCommit

func (g *GitHub) GetLatestCommit(repoPath string) (*CommitInfo, error)

GetLatestCommit gets latest commit info on the repository default branch.

func (*GitHub) ListTags

func (g *GitHub) ListTags(in TagListInput) ([]TagInfo, error)

ListTags lists repository tags by github api.

type TagCommitRef

type TagCommitRef struct {
	SHA string `json:"sha"`
	URL string `json:"url"`
}

TagCommitRef commit info in tag list.

type TagCreateInput

type TagCreateInput struct {
	RepoPath string
	Version  string
	Message  string
	Object   string
	Type     string
	Tagger   Tagger
}

TagCreateInput for creating an annotated tag by GitHub API.

type TagCreateResponse

type TagCreateResponse struct {
	Ref    string    `json:"ref"`
	URL    string    `json:"url,omitempty"`
	Object refObject `json:"object"`
}

TagCreateResponse for created tag ref result.

type TagInfo

type TagInfo struct {
	Name   string       `json:"name"`
	Commit TagCommitRef `json:"commit"`
}

TagInfo represents a github tag item.

type TagListInput

type TagListInput struct {
	RepoPath string
	Limit    int
}

TagListInput for querying tag list.

type Tagger

type Tagger struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	Date  string `json:"date,omitempty"`
}

Tagger info for create annotated tag.

func (Tagger) IsZero

func (t Tagger) IsZero() bool

IsZero checks whether the tagger is empty.

func (Tagger) WithNowDate

func (t Tagger) WithNowDate() Tagger

WithNowDate fills current time when date is empty.

Jump to

Keyboard shortcuts

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