Files
abra/pkg/git/add.go
decentral1se fd81aac7b6
Some checks failed
continuous-integration/drone/push Build is failing
WIP: feat: translation support
See #483
2025-08-23 15:58:32 +02:00

29 lines
459 B
Go

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