git

package module
v0.0.0-...-e0dfb26 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilOpts      = errors.New("options cannot be nil")
	ErrRepoNotFound = errors.New("git repository not found")
)

Errors

View Source
var (
	ErrProviderNotSupported = errors.New("git provider not supported")
)

Errors

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string
	Password string
}

Auth for git provider

type CloneOptions

type CloneOptions struct {
	// URL clone url
	URL string
	// Path where to clone to
	Path string
	Auth *Auth
}

type CreateRepoOptions

type CreateRepoOptions struct {
	Owner   string
	Name    string
	Private bool
}

type GetRepoOptions

type GetRepoOptions struct {
	Owner string
	Name  string
}

type Options

type Options struct {
	Type string
	Auth *Auth
	Host string
}

Options for a new git provider

type Provider

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

	GetRepository(ctx context.Context, opts *GetRepoOptions) (string, error)
}

Provider represents a git provider

func NewProvider

func NewProvider(opts *Options) (Provider, error)

New creates a new git provider

type PushOptions

type PushOptions struct {
	RemoteName string
	Auth       *Auth
}

type Repository

type Repository interface {
	Add(ctx context.Context, pattern string) error

	AddRemote(ctx context.Context, name, url string) error

	// Commits all files and returns the commit sha
	Commit(ctx context.Context, msg string) (string, error)

	Push(context.Context, *PushOptions) error

	IsNewRepo() (bool, error)

	Root() (string, error)
}

Repository represents a git repository

func Clone

func Clone(ctx context.Context, opts *CloneOptions) (Repository, error)

func Init

func Init(ctx context.Context, path string) (Repository, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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