hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit b10381fbe0512a4c2081f7aa5ec97bd74c9f5c50
parent 0eaaa8fee37068bfc8ecfb760f770ecc9a7af22a
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Thu,  2 Dec 2021 16:49:44 +0100

lazy: Reset error in Reset

To prevent sticky errors on server rebuilds.

Fixes #7043
Closes #9194

Diffstat:
Mlazy/init.go | 1+
Mlazy/init_test.go | 19+++++++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/lazy/init.go b/lazy/init.go
@@ -136,6 +136,7 @@ func (ini *Init) shouldInitialize() bool {
 // Reset resets the current and all its dependencies.
 func (ini *Init) Reset() {
 	mu := ini.init.ResetWithLock()
+	ini.err = nil
 	defer mu.Unlock()
 	for _, d := range ini.children {
 		d.Reset()
diff --git a/lazy/init_test.go b/lazy/init_test.go
@@ -220,3 +220,22 @@ func TestInitBranchOrder(t *testing.T) {
 
 	c.Assert(state.V2, qt.Equals, "ABAB")
 }
+
+// See issue 7043
+func TestResetError(t *testing.T) {
+	c := qt.New(t)
+	r := false
+	i := New().Add(func() (interface{}, error) {
+		if r {
+			return nil, nil
+		}
+		return nil, errors.New("r is false")
+	})
+	_, err := i.Do()
+	c.Assert(err, qt.IsNotNil)
+	i.Reset()
+	r = true
+	_, err = i.Do()
+	c.Assert(err, qt.IsNil)
+
+}