diff options
author | Alan Pearce | 2024-06-28 14:36:33 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-28 14:36:33 +0200 |
commit | 32a2145ee44cc301551ce2e4d24ed34361ebd4b2 (patch) | |
tree | 8101f69a0ecc7290720345e905e0e969c6b4372a /internal | |
parent | 0fbf10f9d7bc4991084a2405ba7c3816b3a49e9e (diff) | |
download | website-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.tar.lz website-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.tar.zst website-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.zip |
run `git clean` after updating
Diffstat (limited to 'internal')
-rw-r--r-- | internal/vcs/repository.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/vcs/repository.go b/internal/vcs/repository.go index 8ee08b2..625fbd2 100644 --- a/internal/vcs/repository.go +++ b/internal/vcs/repository.go @@ -81,5 +81,23 @@ func (r *Repository) Update(cfg *Config) (bool, error) { } log.Info("updated to", "rev", head.Hash().String()) - return true, nil + return true, r.Clean(wt) +} + +func (r *Repository) Clean(wt *git.Worktree) error { + st, err := wt.Status() + if err != nil { + return err + } + + if !st.IsClean() { + err = wt.Clean(&git.CleanOptions{ + Dir: true, + }) + if err != nil { + return err + } + } + + return nil } |