Files
abra/pkg/git/remote.go
decentral1se 4e205cf13e
All checks were successful
continuous-integration/drone/push Build is passing
feat: translation support
See #483
2025-08-23 17:55:56 +02:00

30 lines
613 B
Go

package git
import (
"strings"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
)
// CreateRemote creates a new git remote in a repository
func CreateRemote(repo *git.Repository, name, url string, dryRun bool) error {
if dryRun {
log.Debug(i18n.G("dry run: remote %s (%s) not created", name, url))
return nil
}
if _, err := repo.CreateRemote(&config.RemoteConfig{
Name: name,
URLs: []string{url},
}); err != nil {
if !strings.Contains(err.Error(), "remote already exists") {
return err
}
}
return nil
}