Skip to content

Commit

Permalink
hydros automatically committing all files before running a sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Nov 28, 2022
1 parent cee26b5 commit e20ecba
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 25 deletions.
Binary file added .build/hydros
Binary file not shown.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/git_hydros.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

208 changes: 208 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 23 additions & 25 deletions pkg/gitops/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"fmt"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/jlewi/hydros/pkg/gitutil"
"io/ioutil"
"os"
Expand Down Expand Up @@ -634,30 +632,30 @@ func (s *Syncer) PushLocal(wDir string) error {
return errors.Errorf("Could not find remote repo for repository %v/%v", org, repo)
}

head, err := r.Head()
if err != nil {
return err
}
// The refspec to push
dst := fmt.Sprintf("refs/heads/%v", s.manifest.Spec.SourceRepo.Branch)
refSpec := head.Name().String() + ":" + dst

appAuth, err := ssh.NewPublicKeysFromFile("git", "/users/jlewi/.ssh/id_ed25519", "")
if err != nil {
return errors.Wrapf(err, "Failed to load ssh key")
}
//head, err := r.Head()
//if err != nil {
// return err
//}
//// The refspec to push
//dst := fmt.Sprintf("refs/heads/%v", s.manifest.Spec.SourceRepo.Branch)
//refSpec := head.Name().String() + ":" + dst
//
//appAuth, err := ssh.NewPublicKeysFromFile("git", "/users/jlewi/.ssh/id_ed25519", "")
//if err != nil {
// return errors.Wrapf(err, "Failed to load ssh key")
//}
// Push changes to the remote branch.
if err := r.Push(&git.PushOptions{
RemoteName: remoteName,
RefSpecs: []config.RefSpec{
config.RefSpec(refSpec),
},
Progress: os.Stdout,
Force: true,
Auth: appAuth,
}); err != nil {
return err
}
//if err := r.Push(&git.PushOptions{
// RemoteName: remoteName,
// RefSpecs: []config.RefSpec{
// config.RefSpec(refSpec),
// },
// Progress: os.Stdout,
// Force: true,
// Auth: appAuth,
//}); err != nil {
// return err
//}

log.Info("Push succeeded")
return nil
Expand Down

0 comments on commit e20ecba

Please sign in to comment.