forked from toolshed/abra
.gitea
cli
cmd
pkg
app
autocomplete
catalogue
client
compose
config
container
context
dns
envfile
formatter
git
add.go
branch.go
clone.go
commit.go
common.go
diff.go
init.go
push.go
read.go
remote.go
integration
jsontable
limit
lint
log
recipe
secret
server
service
ssh
test
upstream
web
scripts
tests
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
28 lines
420 B
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
|
|
}
|