Run of fresh-releases for golang-github-mitchellh-reflectwalk

Merge these changes:

Summary

Merged new upstream version: 1.0.2 (was: 1.0.1).

Diff

Branch: main

diff --git a/debian/changelog b/debian/changelog
index 21cd6d3..27ead56 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,11 @@
-golang-github-mitchellh-reflectwalk (1.0.1-2) UNRELEASED; urgency=medium
+golang-github-mitchellh-reflectwalk (1.0.2-1) UNRELEASED; urgency=medium
 
   * Set upstream metadata fields: Bug-Database, Bug-Submit, Repository,
     Repository-Browse.
   * Update standards version to 4.5.1, no changes needed.
+  * New upstream release.
 
- -- Debian Janitor <janitor@jelmer.uk>  Fri, 24 Sep 2021 04:18:21 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 14 Mar 2022 21:34:25 -0000
 
 golang-github-mitchellh-reflectwalk (1.0.1-1) unstable; urgency=medium
 
diff --git a/reflectwalk.go b/reflectwalk.go
index 3a93a0b..7fee7b0 100644
--- a/reflectwalk.go
+++ b/reflectwalk.go
@@ -69,6 +69,13 @@ type PointerWalker interface {
 	PointerExit(bool) error
 }
 
+// PointerValueWalker implementations are notified with the value of
+// a particular pointer when a pointer is walked. Pointer is called
+// right before PointerEnter.
+type PointerValueWalker interface {
+	Pointer(reflect.Value) error
+}
+
 // SkipEntry can be returned from walk functions to skip walking
 // the value of this field. This is only valid in the following functions:
 //
@@ -130,6 +137,17 @@ func walk(v reflect.Value, w interface{}) (err error) {
 		}
 
 		if pointerV.Kind() == reflect.Ptr {
+			if pw, ok := w.(PointerValueWalker); ok {
+				if err = pw.Pointer(pointerV); err != nil {
+					if err == SkipEntry {
+						// Skip the rest of this entry but clear the error
+						return nil
+					}
+
+					return
+				}
+			}
+
 			pointer = true
 			v = reflect.Indirect(pointerV)
 		}
diff --git a/reflectwalk_test.go b/reflectwalk_test.go
index 8936a9a..83c49d6 100644
--- a/reflectwalk_test.go
+++ b/reflectwalk_test.go
@@ -49,6 +49,20 @@ func (t *TestPointerWalker) PointerExit(v bool) error {
 	return nil
 }
 
+type TestPointerValueWalker struct {
+	skip     bool
+	pointers []reflect.Type
+}
+
+func (t *TestPointerValueWalker) Pointer(v reflect.Value) error {
+	t.pointers = append(t.pointers, v.Type())
+	if t.skip {
+		return SkipEntry
+	}
+
+	return nil
+}
+
 type TestPrimitiveWalker struct {
 	Value reflect.Value
 }
@@ -482,6 +496,61 @@ func TestWalk_PointerPointer(t *testing.T) {
 	}
 }
 
+func TestWalk_PointerValue(t *testing.T) {
+	type X struct{}
+	type T struct {
+		x *X
+	}
+
+	v := &T{x: &X{}}
+
+	expected := []reflect.Type{
+		reflect.TypeOf(v),
+		reflect.TypeOf(v.x),
+	}
+
+	w := new(TestPointerValueWalker)
+	err := Walk(v, w)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if !reflect.DeepEqual(expected, w.pointers) {
+		t.Fatalf("unexpected pointer order or length (expected len=%d, actual len=%d)", len(expected), len(w.pointers))
+	}
+}
+
+func TestWalk_PointerValueSkip(t *testing.T) {
+	type T struct{}
+	type W struct {
+		TestPointerValueWalker
+		TestPointerWalker
+	}
+
+	v := &T{}
+	w := &W{
+		TestPointerValueWalker: TestPointerValueWalker{
+			skip: true,
+		},
+	}
+	err := Walk(v, w)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if len(w.TestPointerValueWalker.pointers) != 1 {
+		t.Errorf("expected len=1, got len=%d", len(w.TestPointerValueWalker.pointers))
+	}
+
+	if w.TestPointerValueWalker.pointers[0] != reflect.TypeOf(v) {
+		t.Error("pointer value type mismatch")
+	}
+
+	if w.enters != 0 || w.exits != 0 {
+		t.Error("should have been skipped and have zero enters or exits")
+	}
+}
+
 func TestWalk_Slice(t *testing.T) {
 	w := new(TestSliceWalker)
 

Branch: pristine-tar

diff --git a/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.delta b/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.delta
new file mode 100644
index 0000000..095a1d1
Binary files /dev/null and b/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.delta differ
diff --git a/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.id b/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.id
new file mode 100644
index 0000000..07d759d
--- /dev/null
+++ b/golang-github-mitchellh-reflectwalk_1.0.2.orig.tar.gz.id
@@ -0,0 +1 @@
+fd295b6a996c308f60c8ba2d62331c66168d486c

Branch: upstream

Tag: upstream/1.0.2
diff --git a/reflectwalk.go b/reflectwalk.go
index 3a93a0b..7fee7b0 100644
--- a/reflectwalk.go
+++ b/reflectwalk.go
@@ -69,6 +69,13 @@ type PointerWalker interface {
 	PointerExit(bool) error
 }
 
+// PointerValueWalker implementations are notified with the value of
+// a particular pointer when a pointer is walked. Pointer is called
+// right before PointerEnter.
+type PointerValueWalker interface {
+	Pointer(reflect.Value) error
+}
+
 // SkipEntry can be returned from walk functions to skip walking
 // the value of this field. This is only valid in the following functions:
 //
@@ -130,6 +137,17 @@ func walk(v reflect.Value, w interface{}) (err error) {
 		}
 
 		if pointerV.Kind() == reflect.Ptr {
+			if pw, ok := w.(PointerValueWalker); ok {
+				if err = pw.Pointer(pointerV); err != nil {
+					if err == SkipEntry {
+						// Skip the rest of this entry but clear the error
+						return nil
+					}
+
+					return
+				}
+			}
+
 			pointer = true
 			v = reflect.Indirect(pointerV)
 		}
diff --git a/reflectwalk_test.go b/reflectwalk_test.go
index 8936a9a..83c49d6 100644
--- a/reflectwalk_test.go
+++ b/reflectwalk_test.go
@@ -49,6 +49,20 @@ func (t *TestPointerWalker) PointerExit(v bool) error {
 	return nil
 }
 
+type TestPointerValueWalker struct {
+	skip     bool
+	pointers []reflect.Type
+}
+
+func (t *TestPointerValueWalker) Pointer(v reflect.Value) error {
+	t.pointers = append(t.pointers, v.Type())
+	if t.skip {
+		return SkipEntry
+	}
+
+	return nil
+}
+
 type TestPrimitiveWalker struct {
 	Value reflect.Value
 }
@@ -482,6 +496,61 @@ func TestWalk_PointerPointer(t *testing.T) {
 	}
 }
 
+func TestWalk_PointerValue(t *testing.T) {
+	type X struct{}
+	type T struct {
+		x *X
+	}
+
+	v := &T{x: &X{}}
+
+	expected := []reflect.Type{
+		reflect.TypeOf(v),
+		reflect.TypeOf(v.x),
+	}
+
+	w := new(TestPointerValueWalker)
+	err := Walk(v, w)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if !reflect.DeepEqual(expected, w.pointers) {
+		t.Fatalf("unexpected pointer order or length (expected len=%d, actual len=%d)", len(expected), len(w.pointers))
+	}
+}
+
+func TestWalk_PointerValueSkip(t *testing.T) {
+	type T struct{}
+	type W struct {
+		TestPointerValueWalker
+		TestPointerWalker
+	}
+
+	v := &T{}
+	w := &W{
+		TestPointerValueWalker: TestPointerValueWalker{
+			skip: true,
+		},
+	}
+	err := Walk(v, w)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if len(w.TestPointerValueWalker.pointers) != 1 {
+		t.Errorf("expected len=1, got len=%d", len(w.TestPointerValueWalker.pointers))
+	}
+
+	if w.TestPointerValueWalker.pointers[0] != reflect.TypeOf(v) {
+		t.Error("pointer value type mismatch")
+	}
+
+	if w.enters != 0 || w.exits != 0 {
+		t.Error("should have been skipped and have zero enters or exits")
+	}
+}
+
 func TestWalk_Slice(t *testing.T) {
 	w := new(TestSliceWalker)
 

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far. not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 1135, max open: 200)
  • ☑ change set 59992418-47d0-4b27-9b40-9ca2ecf7ed8d is ready

Resulting package

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases golang-github-mitchellh-reflectwalk-dev

Lintian Result

Full worker log Full build log