git

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCodeOwnerRepo

func GetCodeOwnerRepo(codeUrl string) (string, string, error)

GetCodeOwnerRepo 获取代码库的owner以及repo 如:https://github.com/test/testrepo.git -> test,testrepo git@github.com/test/testrepo.git -> test,testrepo

Types

type Client

type Client interface {
	Auth() (transport.AuthMethod, error)
	ListRepositories(ctx context.Context) ([]*Repository, error)
	ListRepoBranches(ctx context.Context, codeUrl string) ([]*Reference, error)
	GetBranchLatestCommit(ctx context.Context, codeUrl, branch string) (*Commit, error)
	Clone(ctx context.Context, repoDir string, isBare bool, options *git.CloneOptions) (*git.Repository, error)
	CreateTag(ctx context.Context, codeUrl, commitId, tagName string) error
}

func NewClient

func NewClient(gitType string, apiUrl string, secret *types.Secret) (Client, error)

type Commit

type Commit struct {
	Branch     string    `json:"branch"`
	CommitId   string    `json:"commit_id"`
	Author     string    `json:"author"`
	Message    string    `json:"message"`
	CommitTime time.Time `json:"commit_time"`
}

type Git

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

func NewGit

func NewGit(secret *types.Secret) *Git

func (*Git) Auth

func (g *Git) Auth() (transport.AuthMethod, error)

func (*Git) Clone

func (g *Git) Clone(ctx context.Context, repoDir string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

func (*Git) CreateTag

func (g *Git) CreateTag(ctx context.Context, codeUrl, commitId, tagName string) error

func (*Git) GetBranchLatestCommit

func (g *Git) GetBranchLatestCommit(ctx context.Context, codeUrl, branch string) (*Commit, error)

func (*Git) ListRepoBranches

func (g *Git) ListRepoBranches(ctx context.Context, codeUrl string) ([]*Reference, error)

func (*Git) ListRepositories

func (g *Git) ListRepositories(ctx context.Context) ([]*Repository, error)

type Gitee

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

func NewGitee

func NewGitee(accessToken string) (*Gitee, error)

func (*Gitee) Auth

func (g *Gitee) Auth() (transport.AuthMethod, error)

func (*Gitee) Clone

func (g *Gitee) Clone(ctx context.Context, repoDir string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

func (*Gitee) CreateTag

func (g *Gitee) CreateTag(ctx context.Context, codeUrl, commitId, tagName string) error

func (*Gitee) GetBranchLatestCommit

func (g *Gitee) GetBranchLatestCommit(ctx context.Context, codeUrl, branch string) (*Commit, error)

func (*Gitee) ListRepoBranches

func (g *Gitee) ListRepoBranches(ctx context.Context, codeUrl string) ([]*Reference, error)

func (*Gitee) ListRepoPullRequests

func (g *Gitee) ListRepoPullRequests(ctx context.Context, codeUrl string) ([]*PullRequest, error)

func (*Gitee) ListRepositories

func (g *Gitee) ListRepositories(ctx context.Context) ([]*Repository, error)

type GiteeBranchCommit

type GiteeBranchCommit struct {
	SHA string `json:"sha"`
	Url string `json:"url"`
}

type GiteeCommit

type GiteeCommit struct {
	Url     string `json:"url"`
	SHA     string `json:"sha"`
	HtmlUrl string `json:"html_url"`
	Commit  struct {
		Author struct {
			Name  string    `json:"name"`
			Date  time.Time `json:"date"`
			Email string    `json:"email"`
		} `json:"author"`
		Message string `json:"message"`
	} `json:"commit"`
}

type GiteeCreateTagRequest

type GiteeCreateTagRequest struct {
	AccessToken string `json:"access_token"`
	Refs        string `json:"refs"`
	TagName     string `json:"tag_name"`
}

type GiteeListPullRequests

type GiteeListPullRequests struct {
	AccessToken string `json:"access_token" url:"access_token"`
	State       string `json:"state" url:"state"`
}

type GiteePullRequest

type GiteePullRequest struct {
	Id        int       `json:"id"`
	Number    int       `json:"int"`
	State     string    `json:"state"`
	Title     string    `json:"title"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type GiteeRepoBranch

type GiteeRepoBranch struct {
	Commit       *GiteeBranchCommit `json:"commit"`
	Name         string             `json:"name"`
	Protected    bool               `json:"protected"`
	ProtectedUrl string             `json:"protected_url"`
}

type GiteeRepoBranchListQuery

type GiteeRepoBranchListQuery struct {
	AccessToken string `json:"access_token" url:"access_token"`
	Owner       string `json:"owner" url:"owner"`
	Repo        string `json:"repo" url:"repo"`
}

type GiteeRepository

type GiteeRepository struct {
	Id       int    `json:"id"`
	Path     string `json:"path"`
	FullName string `json:"full_name"`
	HtmlUrl  string `json:"html_url"`
}

type GiteeRepositoryListQuery

type GiteeRepositoryListQuery struct {
	AccessToken string `json:"access_token" url:"access_token"`
}

type GiteeUser

type GiteeUser struct {
	Id    int    `json:"id"`
	Name  string `json:"name"`
	Login string `json:"login"`
}

type Github

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

func NewGitHub

func NewGitHub(accessToken string) (*Github, error)

func (*Github) Auth

func (g *Github) Auth() (transport.AuthMethod, error)

func (*Github) Clone

func (g *Github) Clone(ctx context.Context, repoDir string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

func (*Github) CreateTag

func (g *Github) CreateTag(ctx context.Context, codeUrl, commitId, tagName string) error

func (*Github) GetBranchLatestCommit

func (g *Github) GetBranchLatestCommit(ctx context.Context, codeUrl, branch string) (*Commit, error)

func (*Github) ListRepoBranches

func (g *Github) ListRepoBranches(ctx context.Context, codeUrl string) ([]*Reference, error)

func (*Github) ListRepoPullRequests

func (g *Github) ListRepoPullRequests(ctx context.Context, codeUrl string) ([]*PullRequest, error)

func (*Github) ListRepoRefs

func (g *Github) ListRepoRefs(ctx context.Context, codeUrl, matchRef string) ([]*Reference, error)

func (*Github) ListRepositories

func (g *Github) ListRepositories(ctx context.Context) ([]*Repository, error)

type Gitlab

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

func NewGitLab

func NewGitLab(apiUrl, accessToken string) (*Gitlab, error)

func (*Gitlab) Auth

func (g *Gitlab) Auth() (transport.AuthMethod, error)

func (*Gitlab) Clone

func (g *Gitlab) Clone(ctx context.Context, repoDir string, isBare bool, options *git.CloneOptions) (*git.Repository, error)

func (*Gitlab) CreateTag

func (g *Gitlab) CreateTag(ctx context.Context, codeUrl, commitId, tagName string) error

func (*Gitlab) GetBranchLatestCommit

func (g *Gitlab) GetBranchLatestCommit(ctx context.Context, codeUrl, branch string) (*Commit, error)

func (*Gitlab) GetPID

func (g *Gitlab) GetPID(codeUrl string) (string, error)

func (*Gitlab) ListRepoBranches

func (g *Gitlab) ListRepoBranches(ctx context.Context, codeUrl string) ([]*Reference, error)

func (*Gitlab) ListRepoPullRequests

func (g *Gitlab) ListRepoPullRequests(ctx context.Context, codeUrl string) ([]*PullRequest, error)

func (*Gitlab) ListRepositories

func (g *Gitlab) ListRepositories(ctx context.Context) ([]*Repository, error)

type PullRequest

type PullRequest struct {
	Number    int       `json:"number"`
	Title     string    `json:"title"`
	State     string    `json:"state"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Username  string    `json:"username"`
}

type Reference

type Reference struct {
	Name     string `json:"name"`
	Ref      string `json:"ref"`
	CommitId string `json:"commit_id"`
}

type Repository

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	CloneUrl string `json:"clone_url"`
}

Jump to

Keyboard shortcuts

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