MCPcopy Create free account
hub / github.com/diillson/chatcli / handleGitDiff

Method handleGitDiff

pkg/coder/engine/commands_git.go:21–49  ·  view source on GitHub ↗
(ctx context.Context, args []string)

Source from the content-addressed store, hash-verified

19}
20
21func (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
51func (e *Engine) handleGitLog(ctx context.Context, args []string) error {
52 fs := flag.NewFlagSet("git-log", flag.ContinueOnError)

Callers 1

ExecuteMethod · 0.95

Calls 4

printCommandOutputMethod · 0.95
runCommandCtxFunction · 0.85
parseFlagsFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected