Skip to content

Commit 24f4d66

Browse files
Add function docs
1 parent 5c320bd commit 24f4d66

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

git/command.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"strings"
77
)
88

9+
// command executes a command with a bunch of options
10+
// It uses a Cmd to run the command with the right context and the correct Executor that can be swapped for
11+
// testing purposes.
912
func command(ctx context.Context, name string, options ...types.Option) (string, error) {
1013
g := types.NewCmd(name)
1114
g.AddOptions(options...)
@@ -14,30 +17,41 @@ func command(ctx context.Context, name string, options ...types.Option) (string,
1417
return strings.TrimSpace(res), err
1518
}
1619

20+
// SetExecutor is the way to substitute the default execution model for testing purposes
1721
func SetExecutor(executor types.Executor) types.Option {
1822
return func(g *types.Cmd) {
1923
g.Executor = executor
2024
}
2125
}
2226

27+
// SetDebug is there to activate debugging for command executions
2328
func SetDebug(debug bool) types.Option {
2429
return func(g *types.Cmd) {
2530
g.Debug = debug
2631
}
2732
}
2833

34+
// Config sets up a `git config` cli command
2935
func Config(options ...types.Option) (string, error) {
3036
return command(context.Background(), "config", options...)
3137
}
38+
39+
// DiffIndex sets up a `git diff-index` cli command
3240
func DiffIndex(options ...types.Option) (string, error) {
3341
return command(context.Background(), "diff-index", options...)
3442
}
43+
44+
// DiffTree sets up a `git diff-tree` cli command
3545
func DiffTree(options ...types.Option) (string, error) {
3646
return command(context.Background(), "diff-tree", options...)
3747
}
48+
49+
// Log sets up a `git log` command
3850
func Log(options ...types.Option) (string, error) {
3951
return command(context.Background(), "log", options...)
4052
}
53+
54+
// RevParse sets up a `git rev-parse` cli command
4155
func RevParse(options ...types.Option) (string, error) {
4256
return command(context.Background(), "rev-parse", options...)
4357
}

0 commit comments

Comments
 (0)