repository

package
v0.0.0-...-0f89c28 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GithubBaseURL
	GithubBaseURL = "https://github.com/"
)
View Source
var (
	// OwnersFileName
	OwnersFileName = "OWNERS"
)

Functions

This section is empty.

Types

type GitClient

type GitClient struct {
	// local mirror dir
	LocalMirrorDir string
	// local repository dir
	LocalRepoDir string
	// github base url
	BaseURL string
	// repository org and name
	Repo string
}

GitClient define

func NewGitClient

func NewGitClient(repo string) (*GitClient, error)

NewGitClient returns a git client. e.g. repo=test/hello

func (*GitClient) CheckOut

func (r *GitClient) CheckOut(branch string, localDir string) error

CheckOut runs the command: git checkout

func (*GitClient) CloneMirror

func (r *GitClient) CloneMirror() error

CloneMirror clones a mirror into local tmp folder

func (*GitClient) CloneRepo

func (r *GitClient) CloneRepo() error

CloneRepo clones a repository into local tmp folder

func (*GitClient) Diff

func (r *GitClient) Diff(head string, sha string) (changes []string, err error)

Diff runs the command: git diff

func (*GitClient) GetLocalRepoDir

func (r *GitClient) GetLocalRepoDir() string

func (*GitClient) RemoveMirror

func (r *GitClient) RemoveMirror() error

RemoveMirror removes tmp local mirror dir

func (*GitClient) RemoveRepo

func (r *GitClient) RemoveRepo() error

RemoveRepo removes tmp local repository dir

type Interface

type Interface interface {
	// Init repository
	Init() error
	// Clear repository
	Clear() error

	// LoadOwners loads an owners list
	LoadOwners(branch string) error

	// GetApproversFilePath returns the OWNERS file path that contains approvers
	GetApproversFilePath(path string) string
	// GetReviewersFilePath returns the OWNERS file path that contains reviewers
	GetReviewersFilePath(path string) string

	// GetClosestApprovers returns a set of users who are the closest approvers
	GetClosestApprovers(path string) map[string]string
	// GetClosestReviewers returns a set of users who are the closest reviewers
	GetClosestReviewers(path string) map[string]string

	// GetAllApprovers returns all the approvers including parent owners file
	GetAllApprovers(path string) map[string]string
	// GetAllReviewers returns all the reviewers including parent owners file
	GetAllReviewers(path string) map[string]string
}

Interface defines for Owners

type OwnersFile

type OwnersFile struct {
	Approvers []string `yaml:"approvers,omitempty"`
	Reviewers []string `yaml:"reviewers,omitempty"`
}

OwnersFile defines the content format of owners file

type Repository

type Repository struct {
	GithubClient *github.Client
	GitClient    *GitClient

	Org  string
	Repo string

	Sha     string
	RepoDir string

	Approvers map[string]map[string]string
	Reviewers map[string]map[string]string
}

Repository cache

func NewRepository

func NewRepository(client *github.Client, repository string) (*Repository, error)

NewRepository returns an repository instance

func (*Repository) Clear

func (o *Repository) Clear() error

Clear repository

func (*Repository) GetAllApprovers

func (o *Repository) GetAllApprovers(path string) map[string]string

GetAllApprovers returns all the approvers including parent owners file

func (*Repository) GetAllReviewers

func (o *Repository) GetAllReviewers(path string) map[string]string

GetAllReviewers returns all the reviewers including parent owners file

func (*Repository) GetApproversFilePath

func (o *Repository) GetApproversFilePath(path string) string

GetApproversFilePath returns the OWNERS file path that contains approvers

func (*Repository) GetClosestApprovers

func (o *Repository) GetClosestApprovers(path string) map[string]string

GetClosestApprovers returns a set of users who are the closest approvers

func (*Repository) GetClosestReviewers

func (o *Repository) GetClosestReviewers(path string) map[string]string

GetClosestReviewers returns a set of users who are the closest reviewers

func (*Repository) GetReviewersFilePath

func (o *Repository) GetReviewersFilePath(path string) string

GetReviewersFilePath returns the OWNERS file path that contains reviewers

func (*Repository) Init

func (o *Repository) Init() error

Init repository

func (*Repository) LoadOwners

func (o *Repository) LoadOwners(branch string) error

LoadOwners loads an owners list

Jump to

Keyboard shortcuts

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