diff options
author | Alan Pearce | 2024-06-29 21:27:35 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-29 21:27:35 +0200 |
commit | 973fa31b6743a3ea84c86ab7671349cc70a69142 (patch) | |
tree | 4c583c8ef5e7a9117fe997a4f861ae7466fa0864 /internal/vcs | |
parent | 7b82d3ef3e93c0c8efe489d6b11b30f092667bf2 (diff) | |
download | website-973fa31b6743a3ea84c86ab7671349cc70a69142.tar.lz website-973fa31b6743a3ea84c86ab7671349cc70a69142.tar.zst website-973fa31b6743a3ea84c86ab7671349cc70a69142.zip |
enable filtered debug logging via DEBUG="component.*"
Diffstat (limited to 'internal/vcs')
-rw-r--r-- | internal/vcs/repository.go | 13 |
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) } |