providers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author added in v0.1.0

type Author struct {
	Name        string
	Email       string
	SlackUserID string
}

Author holds details about the author of a commit

type Authors added in v0.1.0

type Authors []Author

Authors is a slice of Author

type Commit

type Commit struct {
	ID        string
	ShortID   string
	Author    Author
	CreatedAt time.Time
	Message   string
	WebURL    string
}

Commit holds the details of a git commit

func (Commit) AuthorSlackString added in v0.1.0

func (c Commit) AuthorSlackString() string

AuthorSlackString returns a string which can be nicely rendered through Slack

func (Commit) ShortMessage

func (c Commit) ShortMessage() string

ShortMessage truncates commit messages down to 80 chars and omits return carriages

type Commits

type Commits []Commit

Commits is a slice of Commit

type Comparison

type Comparison struct {
	Commits Commits
	WebURL  string
}

Comparison holds the information of a git compare response

func (Comparison) AuthorsSlackString added in v0.1.0

func (c Comparison) AuthorsSlackString() (out string)

AuthorsSlackString returns a string containing authors who contributed within the diff, in a format which can be nicely rendered in Slack

func (Comparison) CommitCount

func (c Comparison) CommitCount() uint

CommitCount returns the amount of commits

func (Comparison) GetAuthors added in v0.1.0

func (c Comparison) GetAuthors() (authors Authors)

GetAuthors returns Authors who appeared to have make contribution(s) in the comparison

func (*Comparison) HydrateCommitsAuthorsWithSlackUserID added in v0.1.0

func (c *Comparison) HydrateCommitsAuthorsWithSlackUserID(mapping map[string]string)

HydrateCommitsAuthorsWithSlackUserID adds the SlackUserID of an author based on its email address

type Provider

type Provider interface {
	WebBaseURL() string
	Type() ProviderType
	Compare(string, Ref, Ref) (*Comparison, error)
	ListRepositories() (Repositories, error)
	ListRefs(string) (Refs, error)
}

Provider is used to represent any kind of git provider

type ProviderType

type ProviderType uint8

ProviderType represents the type of git provider

const (
	// ProviderTypeGitHub for GitHub provider
	ProviderTypeGitHub ProviderType = iota

	// ProviderTypeGitLab for GitLab provider
	ProviderTypeGitLab
)

func GetProviderTypeFromString added in v0.1.0

func GetProviderTypeFromString(p string) (pt ProviderType, err error)

GetProviderTypeFromString returns a ProviderType based onto a given string

func (ProviderType) String

func (pt ProviderType) String() string

String returns the name of the provider (lowercase)

func (ProviderType) StringPretty

func (pt ProviderType) StringPretty() string

StringPretty returns the name of the provider using their capitalization attributes

type Providers

type Providers map[ProviderType]Provider

Providers can store multiple Provider based on their types

func (Providers) ListRepositories

func (ps Providers) ListRepositories() (repos Repositories, err error)

ListRepositories aggregates the repositories for all configured providers

type RankedRef

type RankedRef struct {
	Ref
	Rank int
}

RankedRef can be used when fuzzy searching Refs, attributing a "rank" for the Ref given the pertinence of its attributes given the search

type RankedRefs

type RankedRefs []*RankedRef

RankedRefs is a slice of *RankedRef

type RankedRepositories

type RankedRepositories []*RankedRepository

RankedRepositories is a slice of *RankedRepository

type RankedRepository

type RankedRepository struct {
	Repository
	Rank int
}

RankedRepository can be used when fuzzy searching Repositories, attributing a "rank" for the Repository given the pertinence of its attributes given the search

type Ref

type Ref struct {
	Name   string
	Type   RefType
	WebURL string

	// OriginRef can be used to store the ref onto which a GitLab environment
	// is pointing to
	OriginRef *Ref
}

Ref holds details of a git reference

func (Ref) IsEmpty added in v0.1.0

func (r Ref) IsEmpty() bool

IsEmpty assess the variable is empty or not

func (Ref) Key

func (r Ref) Key() RefKey

Key returns a unique identifier based upon the Type and Name of the Ref

type RefKey

type RefKey string

RefKey is a unique identifier for a Ref

type RefType

type RefType uint8

RefType represents the type of git reference

const (
	// RefTypeBranch represent a git branch
	RefTypeBranch RefType = iota

	// RefTypeCommit represent a git commit
	RefTypeCommit

	// RefTypeEnvironment represent a git environment (only used for GitLab)
	RefTypeEnvironment

	// RefTypeTag represent a git tag
	RefTypeTag
)

func (RefType) String

func (rt RefType) String() string

String returns the type as a readable string

type Refs

type Refs map[RefKey]Ref

Refs holds multiple Ref with their unique identifiers (RefKey)

func (Refs) GetByClosestNameMatch

func (rs Refs) GetByClosestNameMatch(name string) (ref Ref)

GetByClosestNameMatch returns the Ref which is the most pertinent given its Name

func (Refs) GetByKey

func (rs Refs) GetByKey(k RefKey) (r Ref, ok bool)

GetByKey returns a Ref given its RefKey

func (Refs) Search

func (rs Refs) Search(filter string, limit int) (refs RankedRefs)

Search looks up for references by Name in a fuzzy finding fashion, it will return them sorted by pertinence

type Repositories

type Repositories map[RepositoryKey]Repository

Repositories holds multiple Repository with their unique identifiers (RepositoryKey)

func (Repositories) GetByClosestNameMatch

func (rs Repositories) GetByClosestNameMatch(name string) (repo Repository)

GetByClosestNameMatch returns the Repository which is the most pertinent given its Name

func (Repositories) GetByKey

func (rs Repositories) GetByKey(k RepositoryKey) (r Repository, ok bool)

GetByKey returns a Repository given its RepositoryKey

func (Repositories) Search

func (rs Repositories) Search(filter string, limit int) (repos RankedRepositories)

Search looks up for repositories by Name in a fuzzy finding fashion, it will return them sorted by pertinence

type Repository

type Repository struct {
	ProviderType          ProviderType
	Name                  string
	Refs                  Refs
	RefsLastUpdate        time.Time
	RefsCurrentlyUpdating bool
	WebURL                string
}

Repository holds details of a git repository

func (Repository) IsEmpty added in v0.1.0

func (r Repository) IsEmpty() bool

IsEmpty assess the variable is empty or not

func (Repository) Key

func (r Repository) Key() RepositoryKey

Key returns a unique identifier based upon the Name and ProviderType of the Repository

type RepositoryKey

type RepositoryKey string

RepositoryKey is a unique identifier for a Repository

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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