about summary refs log tree commit diff stats
path: root/internal/vcs/repository.go
diff options
context:
space:
mode:
authorAlan Pearce2024-06-28 14:36:33 +0200
committerAlan Pearce2024-06-28 14:36:33 +0200
commit32a2145ee44cc301551ce2e4d24ed34361ebd4b2 (patch)
tree8101f69a0ecc7290720345e905e0e969c6b4372a /internal/vcs/repository.go
parent0fbf10f9d7bc4991084a2405ba7c3816b3a49e9e (diff)
downloadwebsite-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.tar.lz
website-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.tar.zst
website-32a2145ee44cc301551ce2e4d24ed34361ebd4b2.zip
run `git clean` after updating
Diffstat (limited to 'internal/vcs/repository.go')
-rw-r--r--internal/vcs/repository.go20
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
 }