Documentation
¶
Overview ¶
* Wraps access to data needed from Git. * * We invoke Git directly as a subprocess and parse the output rather than using * git2go/libgit2.
Index ¶
- func CommitsWithOpts(ctx context.Context, revs []string, paths []string, filters LogFilters, ...) (iter.Seq2[Commit, error], func() error, error)
- func GetRoot() (_ string, err error)
- func NumCommits(revs []string, paths []string, filters LogFilters) (_ int, err error)
- func ParseArgs(args []string) (revs []string, paths []string, err error)
- func ParseCommits(lines iter.Seq2[string, error]) iter.Seq2[Commit, error]
- func RevList(ctx context.Context, revranges []string, paths []string, filters LogFilters) (_ []string, err error)
- func WorkingTreeFiles(paths []string) (_ map[string]bool, err error)
- type Commit
- type FileAction
- type FileDiff
- type LogFilters
- type Subprocess
- func RunLog(ctx context.Context, revs []string, paths []string, filters LogFilters, ...) (*Subprocess, error)
- func RunLsFiles(ctx context.Context, paths []string) (*Subprocess, error)
- func RunRevList(ctx context.Context, revs []string, paths []string, filters LogFilters, ...) (*Subprocess, error)
- func RunRevParse(ctx context.Context, args []string) (*Subprocess, error)
- func RunStdinLog(ctx context.Context, paths []string, needDiffs bool) (*Subprocess, error)
- type SubprocessErr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitsWithOpts ¶
func CommitsWithOpts( ctx context.Context, revs []string, paths []string, filters LogFilters, populateDiffs bool, ) ( iter.Seq2[Commit, error], func() error, error, )
Returns an iterator over commits identified by the given revisions and paths.
Also returns a closer() function for cleanup and an error when encountered.
func NumCommits ¶
func NumCommits( revs []string, paths []string, filters LogFilters, ) (_ int, err error)
func ParseArgs ¶
Handles splitting the Git revisions from the paths given a list of args.
We call git rev-parse to disambiguate.
func ParseCommits ¶
Turns an iterator over lines from git log into an iterator of commits
Types ¶
type Commit ¶
type FileDiff ¶
type FileDiff struct { Path string Action FileAction LinesAdded int LinesRemoved int MoveDest string // Empty unless the file was renamed }
A file that was changed in a Commit.
type LogFilters ¶
func (LogFilters) ToArgs ¶
func (f LogFilters) ToArgs() []string
Turn into CLI args we can pass to `git log`
type Subprocess ¶
type Subprocess struct {
// contains filtered or unexported fields
}
func RunLog ¶
func RunLog( ctx context.Context, revs []string, paths []string, filters LogFilters, needDiffs bool, ) (*Subprocess, error)
Runs git log
func RunLsFiles ¶
func RunLsFiles(ctx context.Context, paths []string) (*Subprocess, error)
func RunRevList ¶
func RunRevList( ctx context.Context, revs []string, paths []string, filters LogFilters, countOnly bool, ) (*Subprocess, error)
Runs git rev-list. When countOnly is true, passes --count, which is much faster than printing then getting all the revisions when all you need is the count.
func RunRevParse ¶
func RunRevParse(ctx context.Context, args []string) (*Subprocess, error)
Runs git rev-parse
func RunStdinLog ¶
Runs git log --stdin
func (Subprocess) StdinWriter ¶
func (s Subprocess) StdinWriter() (_ *bufio.Writer, closer func() error)
func (Subprocess) StdoutLines ¶
func (s Subprocess) StdoutLines() iter.Seq2[string, error]
Returns a single-use iterator over the output of the command, line by line.
func (Subprocess) Wait ¶
func (s Subprocess) Wait() error
type SubprocessErr ¶
func (SubprocessErr) Error ¶
func (err SubprocessErr) Error() string
func (SubprocessErr) Unwrap ¶
func (err SubprocessErr) Unwrap() error