about summary refs log tree commit diff stats
path: root/internal/vcs
diff options
context:
space:
mode:
Diffstat (limited to 'internal/vcs')
-rw-r--r--internal/vcs/repository.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/vcs/repository.go b/internal/vcs/repository.go
index 1dbf783..017b3d8 100644
--- a/internal/vcs/repository.go
+++ b/internal/vcs/repository.go
@@ -18,9 +18,10 @@ type Config struct {
 
 type Repository struct {
 	repo *git.Repository
+	log  *log.Logger
 }
 
-func CloneOrUpdate(cfg *Config) (*Repository, error) {
+func CloneOrUpdate(cfg *Config, log *log.Logger) (*Repository, error) {
 	gr, err := git.PlainClone(cfg.LocalPath, false, &git.CloneOptions{
 		URL:      cfg.RemoteURL.String(),
 		Progress: os.Stdout,
@@ -35,6 +36,7 @@ func CloneOrUpdate(cfg *Config) (*Repository, error) {
 		}
 		repo := &Repository{
 			repo: gr,
+			log:  log,
 		}
 		_, err := repo.Update()
 		if err != nil {
@@ -46,18 +48,19 @@ func CloneOrUpdate(cfg *Config) (*Repository, error) {
 
 	return &Repository{
 		repo: gr,
+		log:  log,
 	}, nil
 }
 
 func (r *Repository) Update() (bool, error) {
-	log.Info("updating repository")
+	r.log.Info("updating repository")
 
 	head, err := r.repo.Head()
 	if err != nil {
 		return false, err
 	}
 
-	log.Info("updating from", "rev", head.Hash().String())
+	r.log.Info("updating from", "rev", head.Hash().String())
 	wt, err := r.repo.Worktree()
 	if err != nil {
 		return false, err
@@ -68,7 +71,7 @@ func (r *Repository) Update() (bool, error) {
 	})
 	if err != nil {
 		if errors.Is(err, git.NoErrAlreadyUpToDate) {
-			log.Info("already up-to-date")
+			r.log.Info("already up-to-date")
 
 			return true, nil
 		}
@@ -80,7 +83,7 @@ func (r *Repository) Update() (bool, error) {
 	if err != nil {
 		return false, err
 	}
-	log.Info("updated to", "rev", head.Hash().String())
+	r.log.Info("updated to", "rev", head.Hash().String())
 
 	return true, r.Clean(wt)
 }