git

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNothingToCommit    = errors.New("nothing to commit")
	ErrReleaseNotFound    = errors.New("release not found")
	ErrArtifactNotFound   = errors.New("artifact not found")
	ErrBranchBehindOrigin = errors.New("branch behind origin")
	ErrUnknownGit         = errors.New("unknown git error")
)

Functions

func ArtifactCommitMessage added in v0.0.4

func ArtifactCommitMessage(service, artifactID, author string) string

ArtifactCommitMessage returns an artifact commit message.

func BranchFromHead added in v0.0.16

func BranchFromHead(ctx context.Context, repo *git.Repository, artifactFileName, svc string) (string, error)

BranchFromHead reutrns the branch name from the current HEAD commit.

It only handles files that originates from a build operation, ie. non-build commits cannot be extracted.

func BranchName added in v0.0.16

func BranchName(modifiedFiles []string, artifactFileName, svc string) (string, bool)

BranchName returns the branch name and a bool indicating one is found from a list of modified file paths.

It only handles files that originates from a build operation, ie. non-build commits cannot be extracted.

func CommitterDetails

func CommitterDetails() (string, string, error)

CommitterDetails returns name and email read for a Git configuration file.

Configuration files are read first in the local git repository (if available) and then read the global Git configuration.

func PolicyUpdateApplyCommitMessage added in v0.0.4

func PolicyUpdateApplyCommitMessage(env, service, branch, policy string) string

PolicyUpdateApplyCommitMessage returns an apply policy commit message.

func PolicyUpdateDeleteCommitMessage added in v0.0.4

func PolicyUpdateDeleteCommitMessage(service string) string

PolicyUpdateDeleteCommitMessage returns a delete policy commit message.

func ReleaseCommitMessage added in v0.0.4

func ReleaseCommitMessage(env, service, artifactID string) string

ReleaseCommitMessage returns an artifact release commit message.

func RollbackCommitMessage added in v0.0.10

func RollbackCommitMessage(env, service, oldArtifactID, newArtifactID string) string

RollbackCommitMessage returns an artifact rollback commit message.

func TempDir added in v0.0.26

func TempDir(ctx context.Context, tracer tracing.Tracer, prefix string) (string, func(context.Context), error)

TempDir returns a temporary directory with provided prefix. The first return argument is the path. The second is a close function to remove the path.

func TempDirAsync added in v0.0.44

func TempDirAsync(ctx context.Context, tracer tracing.Tracer, prefix string) (string, func(context.Context), error)

TempDirSync returns a temporary directory with provided prefix. The first return argument is the path. The second is a close function to remove the path asynchronously.

Types

type Service added in v0.0.27

type Service struct {
	Tracer            tracing.Tracer
	SSHPrivateKeyPath string
	ConfigRepoURL     string
	// contains filtered or unexported fields
}

func (*Service) Checkout added in v0.0.27

func (s *Service) Checkout(ctx context.Context, rootPath string, hash plumbing.Hash) error

func (*Service) Clone added in v0.0.27

func (s *Service) Clone(ctx context.Context, destination string) (*git.Repository, error)

Clone returns a Git repository copy from the master repository.

func (*Service) Commit added in v0.0.27

func (s *Service) Commit(ctx context.Context, rootPath, changesPath, authorName, authorEmail, committerName, committerEmail, msg string) error

func (*Service) InitMasterRepo added in v0.0.27

func (s *Service) InitMasterRepo(ctx context.Context) (func(context.Context), error)

InitMasterRepo clones the configuration repository into a master directory.

func (*Service) LocateArtifact added in v0.0.27

func (s *Service) LocateArtifact(ctx context.Context, r *git.Repository, artifactID string) (plumbing.Hash, error)

LocateArtifact traverses the git log to find an artifact commit with id artifactID.

It expects the commit to have a commit messages as the one returned by ArtifactCommitMessage.

func (*Service) LocateArtifacts added in v0.0.33

func (s *Service) LocateArtifacts(ctx context.Context, r *git.Repository, service string, n int) ([]plumbing.Hash, error)

LocateArtifacts traverses the git log to find artifact commits for a service.

It expects the commit to have a commit messages as the one returned by ArtifactCommitMessage.

func (*Service) LocateEnvRelease added in v0.0.27

func (s *Service) LocateEnvRelease(ctx context.Context, r *git.Repository, env, artifactID string) (plumbing.Hash, error)

LocateEnvRelease traverses the git log to find a release commit for a specified environment and artifactID.

It expects the commit to have a commit messages as the one returned by ReleaseCommitMessage.

func (*Service) LocateRelease added in v0.0.27

func (s *Service) LocateRelease(ctx context.Context, r *git.Repository, artifactID string) (plumbing.Hash, error)

LocateRelease traverses the git log to find a release commit with id artifactID.

It expects the commit to have a commit messages as the one returned by ReleaseCommitMessage.

func (*Service) LocateServiceRelease added in v0.0.27

func (s *Service) LocateServiceRelease(ctx context.Context, r *git.Repository, env, service string) (plumbing.Hash, error)

LocateServiceRelease traverses the git log to find a release commit for a specified service and environment.

It expects the commit to have a commit messages as the one returned by ReleaseCommitMessage.

func (*Service) LocateServiceReleaseRollbackSkip added in v0.0.27

func (s *Service) LocateServiceReleaseRollbackSkip(ctx context.Context, r *git.Repository, env, service string, n uint) (plumbing.Hash, error)

LocateServiceReleaseRollbackSkip traverses the git log to find a release or rollback commit for a specified service and environment.

It expects the commit to have a commit messages as the one returned by ReleaseCommitMessage or RollbackCommitMessage.

func (*Service) SyncMaster added in v0.0.27

func (s *Service) SyncMaster(ctx context.Context) error

SyncMaster pulls latest changes from master repo.

Jump to

Keyboard shortcuts

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