push using repo instead of remote

This commit is contained in:
Tim Schubert 2022-06-02 20:30:40 +02:00
parent f509136d92
commit 3fbad0b6ab
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA

View file

@ -121,9 +121,9 @@ func CreateRemote(
func Push( func Push(
auth *githttp.BasicAuth, auth *githttp.BasicAuth,
remote *git.Remote, r *git.Repository,
) error { ) error {
return remote.Push(&git.PushOptions{ return r.Push(&git.PushOptions{
RemoteName: DefaultRemoteName, RemoteName: DefaultRemoteName,
Auth: auth, Auth: auth,
}) })
@ -212,13 +212,12 @@ func main() {
Password: *password, Password: *password,
} }
remote, err := CreateRemote(repo, *remoteUrl) if _, err := CreateRemote(repo, *remoteUrl); err != nil {
if err != nil {
log.Fatalf("%s", err) log.Fatalf("%s", err)
} }
if *push == true { if *push == true {
if err := Push(auth, remote); err != nil { if err := Push(auth, repo); err != nil {
if err == git.NoErrAlreadyUpToDate { if err == git.NoErrAlreadyUpToDate {
log.Println("Already up-to-date") log.Println("Already up-to-date")
} else { } else {