repository

package
v0.0.0-...-fa857ea Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTopLevelGitDir

func FindTopLevelGitDir(workingDir string, fs afero.Fs) (string, error)

FindTopLevelGitDir returns the top level git directory for the given working directory

Types

type CommandExecutor

type CommandExecutor interface {
	RunCommand(ctx context.Context, dir string, name string, arg ...string) ([]byte, error)
	RunPipeCommands(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error)
	LookPath(file string) (string, error)
}

type LocalExec

type LocalExec struct{}

func (*LocalExec) LookPath

func (*LocalExec) LookPath(file string) (string, error)

func (*LocalExec) RunCommand

func (le *LocalExec) RunCommand(ctx context.Context, dir string, name string, arg ...string) ([]byte, error)

func (*LocalExec) RunPipeCommands

func (le *LocalExec) RunPipeCommands(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, cmd2Args []string) ([]byte, error)

RunPipeCommands runs two commands in a pipeline. cmd1 | cmd2. Example: /usr/bin/git --no-optional-locks ls-files -s . | /usr/bin/git --no-optional-locks hash-object --stdin

type LocalGit

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

func NewLocalGit

func NewLocalGit(gitPath string, exec CommandExecutor) *LocalGit

func (*LocalGit) Diff

func (lg *LocalGit) Diff(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error)

Diff returns the diff of the repository at the given path

func (*LocalGit) Exists

func (lg *LocalGit) Exists() (string, error)

Exists checks if git binary exists in the system

func (*LocalGit) FixDubiousOwnershipConfig

func (lg *LocalGit) FixDubiousOwnershipConfig(path string) error

FixDubiousOwnershipConfig adds the given path to the git config safe.directory to avoid the dubious ownership error

func (*LocalGit) GetDirContentSHA

func (lg *LocalGit) GetDirContentSHA(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error)

GetDirContentSHA calculates the SHA of the content of the given directory using git ls-files and git hash-object commands

func (*LocalGit) ListUntrackedFiles

func (lg *LocalGit) ListUntrackedFiles(ctx context.Context, repoRoot, workdir string, fixAttempt int) ([]string, error)

func (*LocalGit) Status

func (lg *LocalGit) Status(ctx context.Context, repoRoot, dirPath string, fixAttempt int) (git.Status, error)

Status returns the status of the repository at the given path

type LocalGitInterface

type LocalGitInterface interface {
	Status(ctx context.Context, repoRoot, dirPath string, fixAttempt int) (git.Status, error)
	Exists() (string, error)
	FixDubiousOwnershipConfig(path string) error

	GetDirContentSHA(ctx context.Context, repoRoot, dirPath string, fixAttempt int) (string, error)
	Diff(ctx context.Context, repoRoot, dirPath string, fixAttempt int) (string, error)
	ListUntrackedFiles(ctx context.Context, repoRoot, workdir string, fixAttempt int) ([]string, error)
	// contains filtered or unexported methods
}

type Repository

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

Repository is the struct to check everything related to Git Repo like checking the commit or if the project has changes over it

func NewRepository

func NewRepository(path string) Repository

NewRepository creates a repository controller

func (Repository) GetAnonymizedRepo

func (r Repository) GetAnonymizedRepo() string

GetAnonymizedRepo returns a clean repo url string without sensible information

func (Repository) GetDiffHash

func (r Repository) GetDiffHash(dir string) (string, error)

func (Repository) GetLatestDirSHA

func (r Repository) GetLatestDirSHA(dir string) (string, error)

func (Repository) GetSHA

func (r Repository) GetSHA() (string, error)

GetSHA returns the last commit sha of the repository

func (Repository) IsClean

func (r Repository) IsClean() (bool, error)

IsClean checks if the repository have changes over the commit

func (Repository) IsEqual

func (r Repository) IsEqual(otherRepo Repository) bool

IsEqual checks if another repository is the same from the one calling the function

Jump to

Keyboard shortcuts

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