repository

package
v0.0.0-...-4c4ccab Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMalformatedFilterExpression error = errors.New("malformated filter expression")
	ErrUnknownFilterKey            error = errors.New("unknown filter key")
)
View Source
var (
	ErrUnauthenticated        error = errors.New("unauthenticated")
	ErrUnconfiguredRepository error = errors.New("unconfigured repository")
	ErrRepositoryNotCached    error = errors.New("repository not cached")
	ErrRepositoryDoesntExist  error = errors.New("repository doesnt exist")
	ErrRepositoryAlreadyExist error = errors.New("repository already exist")
)

Functions

func ByBranch

func ByBranch(a, b *Repository) bool

Sort two repositories by branch

func ByName

func ByName(a, b *Repository) bool

Sort two repositories by name

func ByType

func ByType(a, b *Repository) bool

Sort two repositories by type

func NoFilter

func NoFilter(r *Repository) bool

NoFilter will not filter out any repository.

Types

type By

type By func(a, b *Repository) bool

By can sort two Repositories

func SortBy

func SortBy(fieldPath string) By

SortBy takes a field path and returns the equivalent Sorter function

func (By) Sort

func (by By) Sort(subject []*Repository)

Sort does an in-place sort of the supplied repositories

type Filter

type Filter func(r *Repository) bool

A Filter is a prototype for a function that can be used to filter the results from a call to the List() method on the Manager.

func BranchFilter

func BranchFilter(branch string) Filter

BranchFilter filters all repositories whose current branch matches the given branch name.

func BuildFilters

func BuildFilters(expression string) ([]Filter, error)

BuildFilters takes an expression string and returns a list of Filter functions. Example: "branch=main type=controller"

func NameFilter

func NameFilter(name string) Filter

NameFilter filters all repositories whose names matches the specified name

func NamePrefixFilter

func NamePrefixFilter(namePrefix string) Filter

NamePrefixFilter filters all repositories whose name prefix matches the the given namePrefix

func TypeFilter

func TypeFilter(t string) Filter

TypeFilter filters a repository by a name prefix The only two possible types are 'controller' and 'core'

type Manager

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

Manager is reponsible of managing local ACK local repositories and github forks.

func NewManager

func NewManager(cfg *config.Config) (*Manager, error)

NewManager create a new manager.

func (*Manager) AddRepository

func (m *Manager) AddRepository(name string, t RepositoryType) (*Repository, error)

AddRepository creates a new Repository object and adds it to the cache.

func (*Manager) EnsureAll

func (m *Manager) EnsureAll(ctx context.Context) error

EnsureAll ensures all cached repositories.

func (*Manager) EnsureClone

func (m *Manager) EnsureClone(ctx context.Context, repo *Repository) error

func (*Manager) EnsureFork

func (m *Manager) EnsureFork(ctx context.Context, repo *Repository) error

ensureFork ensures that your github account have a fork for a given ACK project. It will also rename the project if it's not following the standard: $ackprefix-$projectname

func (*Manager) EnsureRemotes

func (m *Manager) EnsureRemotes(ctx context.Context, repo *Repository) error

EnsureRemotes ensures that the local repositories have both origin and upstream remotes setup and point to the correct URLs.

func (*Manager) EnsureRepository

func (m *Manager) EnsureRepository(ctx context.Context, name string) error

EnsureRepository ensures the current user owns a fork of the given repository and has cloned it.

func (*Manager) List

func (m *Manager) List(filters ...Filter) []*Repository

List returns the list of all the cached repositories

func (*Manager) LoadAll

func (m *Manager) LoadAll() error

LoadAll parses the configuration and loads informations about local repositories if they are found.

func (*Manager) LoadRepository

func (m *Manager) LoadRepository(name string, t RepositoryType) (*Repository, error)

LoadRepository loads information about a single local repository

type Repository

type Repository struct {

	// Name of the ACK upstream repo
	Name string
	// Repository Type
	Type RepositoryType
	// Expected fork name. Generally looking like ack-sagemaker
	ExpectedForkName string
	// Expected local full path
	FullPath string
	// Git HEAD commit or current branch
	GitHead string
	// contains filtered or unexported fields
}

Repository represents an ACK project repository.

func NewRepository

func NewRepository(name string, repoType RepositoryType) *Repository

NewRepository returns a pointer to a new repository.

type RepositoryType

type RepositoryType int
const (
	RepositoryTypeCore RepositoryType = iota
	RepositoryTypeTooling
	RepositoryTypeController
	RepositoryTypeUnknown
)

func GetRepositoryTypeFromString

func GetRepositoryTypeFromString(s string) RepositoryType

GetRepositoryTypeFromString casts a string to a RepositoryType

func (RepositoryType) String

func (rt RepositoryType) String() string

String stringifies a Repository type

Jump to

Keyboard shortcuts

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