run `git clean` after updating
Alan Pearce alan@alanpearce.eu
Fri, 28 Jun 2024 14:36:33 +0200
1 files changed, 19 insertions(+), 1 deletions(-)
jump to
M internal/vcs/repository.go → internal/vcs/repository.go
@@ -81,5 +81,23 @@ return false, err } 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 }