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

Method updateCmd

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

Source from the content-addressed store, hash-verified

404}
405
406func (a *App) updateCmd() error {
407 files, err := a.repo.ListModified("file-only")
408 if err != nil {
409 return err
410 }
411
412 if len(files) == 0 {
413 return nil
414 }
415
416 var fileItems []interface{}
417 for _, file := range files {
418 fileItems = append(fileItems, file)
419 }
420
421 fmt.Printf(a.colored(a.colors.HeaderColor, "%12s %12s %s\n"), "staged", "unstaged", "path")
422 chosen, err := a.listAndChoose("Update", fileItems, false, false)
423 if err != nil {
424 return err
425 }
426
427 if len(chosen) > 0 {
428 var paths []string
429 for _, item := range chosen {
430 file := item.(git.FileStatus)
431 paths = append(paths, file.Path)
432 }
433
434 args := append([]string{"update-index", "--add", "--remove", "--"}, paths...)
435 _, err := a.repo.RunCommand(args...)
436 if err != nil {
437 return err
438 }
439
440 fmt.Printf("updated %d path(s)\n", len(paths))
441 }
442
443 fmt.Println()
444 return nil
445}
446
447func (a *App) revertCmd() error {
448 files, err := a.repo.ListModified("")

Callers

nothing calls this directly

Calls 4

coloredMethod · 0.95
listAndChooseMethod · 0.95
ListModifiedMethod · 0.80
RunCommandMethod · 0.80

Tested by

no test coverage detected