package git import ( "github.com/go-git/go-git/v5" "github.com/sirupsen/logrus" ) // Add adds a file to the git index. func Add(repoPath, path string, dryRun bool) error { repo, err := git.PlainOpen(repoPath) if err != nil { return err } worktree, err := repo.Worktree() if err != nil { return err } if dryRun { logrus.Debugf("dry run: adding %s", path) } else { worktree.Add(path) } return nil }