MCPcopy Create free account
hub / github.com/cwarden/git-add--interactive / patchCmd

Method patchCmd

internal/ui/app.go:544–587  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

542}
543
544func (a *App) patchCmd() error {
545 files, err := a.repo.ListModified("file-only")
546 if err != nil {
547 return err
548 }
549
550 if len(files) == 0 {
551 fmt.Println("No changes.")
552 fmt.Println()
553 return nil
554 }
555
556 var fileItems []interface{}
557 for _, file := range files {
558 if !file.Unmerged && !file.Binary {
559 fileItems = append(fileItems, file)
560 }
561 }
562
563 if len(fileItems) == 0 {
564 fmt.Println("No changes.")
565 fmt.Println()
566 return nil
567 }
568
569 fmt.Printf(a.colored(a.colors.HeaderColor, "%12s %12s %s\n"), "staged", "unstaged", "path")
570 chosen, err := a.listAndChoose("Patch update", fileItems, false, false)
571 if err != nil {
572 return err
573 }
574
575 if len(chosen) > 0 {
576 var paths []string
577 for _, item := range chosen {
578 file := item.(git.FileStatus)
579 paths = append(paths, file.Path)
580 }
581
582 return a.RunPatchMode("stage", "", paths)
583 }
584
585 fmt.Println()
586 return nil
587}
588
589func (a *App) diffCmd() error {
590 files, err := a.repo.ListModified("index-only")

Callers

nothing calls this directly

Calls 4

coloredMethod · 0.95
listAndChooseMethod · 0.95
RunPatchModeMethod · 0.95
ListModifiedMethod · 0.80

Tested by

no test coverage detected