(ctx context.Context, args []string)
| 19 | } |
| 20 | |
| 21 | func (e *Engine) handleGitDiff(ctx context.Context, args []string) error { |
| 22 | fs := flag.NewFlagSet("git-diff", flag.ContinueOnError) |
| 23 | dir := fs.String("dir", ".", "") |
| 24 | staged := fs.Bool("staged", false, "") |
| 25 | nameOnly := fs.Bool("name-only", false, "") |
| 26 | stat := fs.Bool("stat", false, "") |
| 27 | path := fs.String("path", "", "") |
| 28 | context := fs.Int("context", 3, "") |
| 29 | if err := parseFlags(fs, args); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | |
| 33 | cmdArgs := []string{"diff", fmt.Sprintf("--unified=%d", *context)} |
| 34 | if *staged { |
| 35 | cmdArgs = append(cmdArgs, "--staged") |
| 36 | } |
| 37 | if *nameOnly { |
| 38 | cmdArgs = append(cmdArgs, "--name-only") |
| 39 | } |
| 40 | if *stat { |
| 41 | cmdArgs = append(cmdArgs, "--stat") |
| 42 | } |
| 43 | if *path != "" { |
| 44 | cmdArgs = append(cmdArgs, "--", *path) |
| 45 | } |
| 46 | |
| 47 | out, err := runCommandCtx(ctx, *dir, "git", cmdArgs...) |
| 48 | return e.printCommandOutput(out, err) |
| 49 | } |
| 50 | |
| 51 | func (e *Engine) handleGitLog(ctx context.Context, args []string) error { |
| 52 | fs := flag.NewFlagSet("git-log", flag.ContinueOnError) |
no test coverage detected