utils

package module
v0.0.0-...-5d48d43 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffContents

func DiffContents(src string, dst string) []diffmatchpatch.Diff

FIXME remove later if not used

func ExecCommitsInRange

func ExecCommitsInRange(repoDir string, branch string, since string, until string) ([]string, error)

func ExecDiffIsBinary

func ExecDiffIsBinary(repoDir string, commitId string, filePath string) (bool, error)

func ExecDiffTree

func ExecDiffTree(repoDir string, commitId1 string) ([]string, error)

func ExecGetCommitAtDate

func ExecGetCommitAtDate(repoDir string, branch string, when string) (string, error)

FIXME check if this is used and delete it

func ExecListTree

func ExecListTree(repoDir string, commitId string) ([]string, error)

func ExecPreviousCommitIdForFile

func ExecPreviousCommitIdForFile(repoDir string, commitId string, filePath string) (string, error)

func ExecShell

func ExecShell(workingDir string, command string) (string, error)

ExecShell execute a shell command (like bash -c 'your command')

func ExecShellTimeout

func ExecShellTimeout(workingDir string, command string, timeout time.Duration, expectedExitCodes []int) (string, error)

ExecShellTimeout execute a shell command (like bash -c 'your command') with a timeout. After that time, the process will be cancelled

func ExecShellf

func ExecShellf(workingDir string, command string, args ...interface{}) (string, error)

ExecShellf execute a shell command (like bash -c 'your command') but with format replacements

func ExecTreeFileSize

func ExecTreeFileSize(repoDir string, commitId string, filePath string) (int, error)

func GetCmdOutput

func GetCmdOutput(cmd *cmd.Cmd) string

GetCmdOutput join stdout and stderr in a single string from Cmd

func ResolveTestOwnershipRepo

func ResolveTestOwnershipRepo() (string, error)

func ShowProgress

func ShowProgress(progressChan <-chan ProgressInfo)

Types

type BaseOptions

type BaseOptions struct {
	Branch     string
	FilesRegex string
	RepoDir    string
}

type BlameLine

type BlameLine struct {
	// AuthorName is the name of the last author that modified the line
	AuthorName string
	// AuthorMail is the mail of the last author that modified the line
	AuthorMail string
	// Date is when the original text of the line was introduced
	AuthorDate time.Time
	// Hash is the commit hash that introduced the original line
	CommitId     string
	LineContents string
}

func ExecGitBlame

func ExecGitBlame(repoPath string, filePath string, revision string) ([]BlameLine, error)

type CommitInfo

type CommitInfo struct {
	AuthorName string
	AuthorMail string
	Date       time.Time
}

func ExecGitCommitInfo

func ExecGitCommitInfo(repoDir string, commitId string) (CommitInfo, error)

type DiffEntry

type DiffEntry struct {
	Operation DiffOp
	SrcLines  []LineText
	DstLines  []LineText
}

func ExecDiffFileRevisions

func ExecDiffFileRevisions(repoDir string, filePath string, srcCommitId string, dstCommitId string) ([]DiffEntry, error)

func ExecDiffFiles

func ExecDiffFiles(fileSrc string, fileDst string) ([]DiffEntry, error)

func ParseNormalDiffOutput

func ParseNormalDiffOutput(contents string) ([]DiffEntry, error)

type DiffOp

type DiffOp int
const (
	OperationAdd DiffOp = iota
	OperationDelete
	OperationChange
)

type LineText

type LineText struct {
	Number int
	Text   string
}

type ProgressInfo

type ProgressInfo struct {
	TotalTasks         int
	TotalTasksKnown    bool
	CompletedTasks     int
	CompletedTotalTime time.Duration
	Message            string
}

Jump to

Keyboard shortcuts

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