Documentation ¶
Index ¶
- func FindTopLevelGitDir(workingDir string, fs afero.Fs) (string, error)
- type CommandExecutor
- type LocalExec
- func (*LocalExec) LookPath(file string) (string, error)
- func (le *LocalExec) RunCommand(ctx context.Context, dir string, name string, arg ...string) ([]byte, error)
- func (le *LocalExec) RunPipeCommands(ctx context.Context, dir string, cmd1 string, cmd1Args []string, cmd2 string, ...) ([]byte, error)
- type LocalGit
- func (lg *LocalGit) Diff(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error)
- func (lg *LocalGit) Exists() (string, error)
- func (lg *LocalGit) FixDubiousOwnershipConfig(path string) error
- func (lg *LocalGit) GetDirContentSHA(ctx context.Context, gitPath, dirPath string, fixAttempt int) (string, error)
- func (lg *LocalGit) ListUntrackedFiles(ctx context.Context, repoRoot, workdir string, fixAttempt int) ([]string, error)
- func (lg *LocalGit) Status(ctx context.Context, repoRoot, dirPath string, fixAttempt int) (git.Status, error)
- type LocalGitInterface
- type Repository
- func (r Repository) GetAnonymizedRepo() string
- func (r Repository) GetDiffHash(dir string) (string, error)
- func (r Repository) GetLatestDirSHA(dir string) (string, error)
- func (r Repository) GetSHA() (string, error)
- func (r Repository) IsClean() (bool, error)
- func (r Repository) IsEqual(otherRepo Repository) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommandExecutor ¶
type LocalExec ¶
type LocalExec struct{}
func (*LocalExec) RunCommand ¶
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) FixDubiousOwnershipConfig ¶
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 ¶
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