Files
abra/pkg/git/add.go
decentral1se ff32c06676
All checks were successful
continuous-integration/drone/push Build is passing
feat: translation support
See #483
2025-08-19 16:07:24 +02:00

29 lines
469 B
Go

package git
import (
"coopcloud.tech/abra/pkg/log"
"github.com/go-git/go-git/v5"
"github.com/leonelquinteros/gotext"
)
// 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 {
log.Debugf(gotext.Get("dry run: adding %s", path))
} else {
worktree.Add(path)
}
return nil
}