func Exec(ctx context.Context, repoPath string, filePattern string, additionalFlags []string) (Result, error) {
	gitPath, err := exec.LookPath("git")
	if err != nil {
		return nil, fmt.Errorf("could not find git: %w", err)
	}

	args := []string{"log"}

	// TODO we should allow a way for the caller to specify additional flags (in a way that doesn't conflict with these)
	args = append(args, "--numstat", "--format=fuller", "--no-merges", "--no-decorate", "--date=iso8601-strict", "-w")
	args = append(args, additionalFlags...)
	if filePattern != "" {
		args = append(args, filePattern)
	}

	cmd := exec.CommandContext(ctx, gitPath, args...)
	cmd.Dir = repoPath

	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, err
	}

	stderr, err := cmd.StderrPipe()
	if err != nil {
		return nil, err
	}

	if err := cmd.Start(); err != nil {
		return nil, err
	}

	res, err := parseLog(stdout)
	if err != nil {
		return nil, err
	}

	errs, err := ioutil.ReadAll(stderr)
	if err != nil {
		return nil, err
	}

	if err := cmd.Wait(); err != nil {
		fmt.Println(string(errs))
		return nil, err
	}

	return res, nil
}
// Exec runs the git log command
Exec runs the git log command
// Exec runs the git log command
func Exec(ctx context.Context, repoPath string, filePattern string, additionalFlags []string) (Result, error) {
	gitPath, err := exec.LookPath("git")
	if err != nil {
		return nil, fmt.Errorf("could not find git: %w", err)
	}
	args := []string{"log"}
	args = append(args, "--numstat", "--format=fuller", "--no-merges", "--no-decorate", "--date=iso8601-strict", "-w")
	args = append(args, additionalFlags...)
	if filePattern != "" {
		args = append(args, filePattern)
	}
	cmd := exec.CommandContext(ctx, gitPath, args...)
	cmd.Dir = repoPath
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return nil, err
	}
	stderr, err := cmd.StderrPipe()
	if err != nil {
		return nil, err
	}
	if err := cmd.Start(); err != nil {
		return nil, err
	}
	res, err := parseLog(stdout)
	if err != nil {
		return nil, err
	}
	errs, err := ioutil.ReadAll(stderr)
	if err != nil {
		return nil, err
	}
	if err := cmd.Wait(); err != nil {
		fmt.Println(string(errs))
		return nil, err
	}
	return res, nil
}
func Exec ( ctx context . Context , repoPath string , filePattern string , additionalFlags [ ] string ) ( Result , error ) { gitPath , err := exec . LookPath ( " " ) if err != nil { return nil , fmt . Errorf ( " " , err ) } args := [ ] string { " " } args = append ( args , " " , " " , " " , " " , " " , " " ) args = append ( args , additionalFlags ... ) if filePattern != " " { args = append ( args , filePattern ) } cmd := exec . CommandContext ( ctx , gitPath , args ... ) cmd . Dir = repoPath stdout , err := cmd . StdoutPipe ( ) if err != nil { return nil , err } stderr , err := cmd . StderrPipe ( ) if err != nil { return nil , err } if err := cmd . Start ( ) ; err != nil { return nil , err } res , err := parseLog ( stdout ) if err != nil { return nil , err } errs , err := ioutil . ReadAll ( stderr ) if err != nil { return nil , err } if err := cmd . Wait ( ) ; err != nil { fmt . Println ( string ( errs ) ) return nil , err } return res , nil }
Exec runs the git log command
Exec runs the git log command
// TODO we should allow a way for the caller to specify additional flags (in a way that doesn't conflict with these)