Files
.gitea
cli
cmd
pkg
app
autocomplete
catalogue
client
config
container
context
dns
envfile
formatter
git
add.go
branch.go
clone.go
commit.go
common.go
diff.go
init.go
init_test.go
push.go
read.go
read_test.go
remote.go
integration
limit
lint
log
recipe
secret
server
service
ssh
test
upstream
web
scripts
tests
vendor
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
abra/pkg/git/add.go

28 lines
420 B
Go

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