git

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 40 Imported by: 6

Documentation

Index

Constants

View Source
const Azure = "azure"
View Source
const AzureHostName = "dev.azure"
View Source
const BitbucketServer = "bitbucket-server"

Variables

View Source
var (
	ErrProviderNotSupported = func(providerType string) error {
		return fmt.Errorf("git provider '%s' not supported", providerType)
	}
	ErrAuthenticationFailed = func(err error) error {
		return fmt.Errorf("authentication failed, make sure credentials are correct: %w", err)
	}
)

Errors

View Source
var (
	ErrNilOpts      = errors.New("options cannot be nil")
	ErrNoParse      = errors.New("must call Parse before using CloneOptions")
	ErrRepoNotFound = errors.New("git repository not found")
	ErrNoRemotes    = errors.New("no remotes in repository")
)

Errors

Functions

func DefaultTransportWithCa added in v0.4.8

func DefaultTransportWithCa(certFile string) (*http.Transport, error)

func Providers

func Providers() []string

Types

type AddFlagsOptions added in v0.2.8

type AddFlagsOptions struct {
	FS               billy.Filesystem
	Prefix           string
	CreateIfNotExist bool
	// CloneForWrite if true will not allow 'ref' query param which is not
	// a branch name
	CloneForWrite bool
	Optional      bool
}

type AdoClient added in v0.2.28

type AdoClient interface {
	CreateRepository(context.Context, ado.CreateRepositoryArgs) (*ado.GitRepository, error)
	GetRepository(context.Context, ado.GetRepositoryArgs) (*ado.GitRepository, error)
}

type AdoUrl added in v0.2.28

type AdoUrl interface {
	GetProjectName() string
}

type Auth

type Auth struct {
	Username string
	Password string
	CertFile string
}

func (*Auth) GetCertificate added in v0.4.8

func (a *Auth) GetCertificate() ([]byte, error)

type Client added in v0.2.10

type Client interface {
	CreateOrgRepo(org string, opt gt.CreateRepoOption) (*gt.Repository, *gt.Response, error)
	CreateRepo(opt gt.CreateRepoOption) (*gt.Repository, *gt.Response, error)
	GetRepo(owner, reponame string) (*gt.Repository, *gt.Response, error)
	GetMyUserInfo() (*gt.User, *gt.Response, error)
}

type CloneOptions

type CloneOptions struct {
	Provider         string
	Repo             string
	Auth             Auth
	FS               fs.FS
	Progress         io.Writer
	CreateIfNotExist bool
	CloneForWrite    bool
	UpsertBranch     bool
	// contains filtered or unexported fields
}

func AddFlags

func AddFlags(cmd *cobra.Command, opts *AddFlagsOptions) *CloneOptions

func (*CloneOptions) GetRepo added in v0.2.8

func (o *CloneOptions) GetRepo(ctx context.Context) (Repository, fs.FS, error)

func (*CloneOptions) Parse added in v0.2.0

func (o *CloneOptions) Parse()

func (*CloneOptions) Path added in v0.2.0

func (o *CloneOptions) Path() string

func (*CloneOptions) Revision

func (o *CloneOptions) Revision() string

func (*CloneOptions) URL

func (o *CloneOptions) URL() string

type CreateRepoOptions

type CreateRepoOptions struct {
	Owner   string
	Name    string
	Private bool
}

type GetRepoOptions

type GetRepoOptions struct {
	Owner string
	Name  string
}

type GitlabClient added in v0.2.26

type GitlabClient interface {
	CurrentUser(options ...gl.RequestOptionFunc) (*gl.User, *gl.Response, error)
	CreateProject(opt *gl.CreateProjectOptions, options ...gl.RequestOptionFunc) (*gl.Project, *gl.Response, error)
	GetProject(pid interface{}, opt *gl.GetProjectOptions, options ...gl.RequestOptionFunc) (*gl.Project, *gl.Response, error)
	GetGroup(gid interface{}, opt *gl.GetGroupOptions, options ...gl.RequestOptionFunc) (*gl.Group, *gl.Response, error)
}

type HttpClient added in v0.4.0

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}
type Link struct {
	Name string `json:"name"`
	Href string `json:"href"`
}
type Links struct {
	Clone []Link `json:"clone"`
}

type Provider

type Provider interface {
	// CreateRepository creates the repository in the remote provider and returns a
	// clone url
	CreateRepository(ctx context.Context, orgRepo string) (defaultBranch string, err error)

	// GetDefaultBranch returns the default branch of the repository
	GetDefaultBranch(ctx context.Context, orgRepo string) (string, error)

	// GetAuthor gets the authenticated user's name and email address, for making git commits.
	// Returns empty strings if not implemented
	GetAuthor(ctx context.Context) (username, email string, err error)
}

Provider represents a git provider

type ProviderOptions

type ProviderOptions struct {
	Type    string
	Auth    *Auth
	RepoURL string
}

ProviderOptions for a new git provider

type PushOptions

type PushOptions struct {
	Provider       string
	AddGlobPattern string
	CommitMsg      string
	Progress       io.Writer
}

type Repository

type Repository interface {
	// Persist runs add, commit and push to the repository default remote
	Persist(ctx context.Context, opts *PushOptions) (string, error)
	// CurrentBranch returns the name of the current branch
	CurrentBranch() (string, error)
}

Repository represents a git repository

Directories

Path Synopsis
ado
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
bitbucket
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
bitbucket-server
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
gitea
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
gitlab
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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