git

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheTimeout  = 2 * time.Minute
	DefaultBranch = "_base"
)
View Source
const MaxCommitRetry = 3

Variables

View Source
var DefaultCommiter = &Commiter{
	Name:  "service",
	Email: "service@kubgems.io",
}

Functions

func ForFileContentFunc

func ForFileContentFunc(fs billy.Filesystem, base string, fun func(filename string, content []byte) error) error

func ForFileNameFunc

func ForFileNameFunc(fs billy.Filesystem, base string, fun func(filename string) error) error

ForFileNameFunc filename 为 base 下的全路径

Types

type Commit

type Commit struct {
	Author    object.Signature `json:"author"`
	Message   string           `json:"message"`
	Hash      string           `json:"hash"`
	Committer object.Signature `json:"committer"`
	Files     []CommitFile     `json:"files"`
}

type CommitFile

type CommitFile struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

type CommitMessage

type CommitMessage struct {
	Message   string
	Committer *object.Signature
}

type Commiter

type Commiter struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

type ContentUpdateFunc

type ContentUpdateFunc = func(ctx context.Context, fs billy.Filesystem) error

type ContentVistitFunc

type ContentVistitFunc func(ctx context.Context, commit Commit) error

type FileDiff

type FileDiff struct {
	Name string `json:"name"`
	From string `json:"from"`
	To   string `json:"to"`
}

type GitHandler

type GitHandler = SimpleLocalProvider

type GiteaRemote

type GiteaRemote struct {
	*gitea.Client
}

func (*GiteaRemote) EnsureRepo

func (h *GiteaRemote) EnsureRepo(ctx context.Context, orgname, reponame string) (*gitea.Repository, error)

type Options

type Options struct {
	Addr     string `json:"addr" description:"git addr"`
	Username string `json:"username" description:"git username"`
	Password string `json:"password" description:"git password"`
}

func NewDefaultOptions

func NewDefaultOptions() *Options

type Repository

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

func (*Repository) CloneURL

func (r *Repository) CloneURL() string

func (*Repository) CommitPush

func (r *Repository) CommitPush(ctx context.Context, path string, commit *CommitMessage) error

func (*Repository) CommitPushWithRetry

func (r *Repository) CommitPushWithRetry(ctx context.Context, path string, commit *CommitMessage) error

func (*Repository) ContentFunc

func (r *Repository) ContentFunc(ctx context.Context, path string, fun ContentUpdateFunc) error

ContentFunc change fs content and do a commit if commit is not nil

func (*Repository) Diff

func (r *Repository) Diff(ctx context.Context, path string, hash string) ([]FileDiff, error)

func (*Repository) Expired

func (r *Repository) Expired() bool

func (*Repository) Filesystem

func (r *Repository) Filesystem(ctx context.Context, path string) (billy.Filesystem, error)

func (*Repository) HistoryFiles

func (r *Repository) HistoryFiles(ctx context.Context, path string, rev string) (*Commit, error)

func (*Repository) HistoryFunc

func (r *Repository) HistoryFunc(ctx context.Context, path string, fun ContentVistitFunc) error

func (*Repository) Pull

func (r *Repository) Pull(ctx context.Context) error

type RepositoryRef

type RepositoryRef struct {
	Org    string `json:"org,omitempty"`
	Repo   string `json:"repo,omitempty"`
	Branch string `json:"branch,omitempty"`
	Path   string `json:"path,omitempty"`
}

type RevMeta

type RevMeta struct {
	Hash    string
	Author  string
	Date    metav1.Time
	Message string
}

type SimpleLocalProvider

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

func NewProvider

func NewProvider(options *Options) (*SimpleLocalProvider, error)

func (*SimpleLocalProvider) GenerateCloneURL

func (p *SimpleLocalProvider) GenerateCloneURL(ctx context.Context, ref RepositoryRef) string

func (*SimpleLocalProvider) Get

func (*SimpleLocalProvider) GetRemoteRepoRevMeta

func (p *SimpleLocalProvider) GetRemoteRepoRevMeta(ctx context.Context, repourl string, branchOrRev string) (*RevMeta, error)

func (*SimpleLocalProvider) Options

func (p *SimpleLocalProvider) Options() *Options

Jump to

Keyboard shortcuts

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