@@ -4,24 +4,14 @@ import (
44 "reflect"
55 "strings"
66
7- "github.com/goreleaser/goreleaser-mcp/internal/yaml"
87 "github.com/goreleaser/goreleaser-pro/v2/pkg/config"
98)
109
11- // parse reads a goreleaser configuration from a byte slice and returns a config.Project.
12- func parse (in []byte ) (* config.Project , error ) {
13- var out config.Project
14- if err := yaml .UnmarshalStrict (in , & out ); err != nil {
15- return nil , err
16- }
17- return & out , nil
18- }
19-
2010// findDeprecated returns a map of deprecated fields that have non-zero values.
2111// The keys are the composed field names (e.g., 'archives.builds', 'brews').
2212func findDeprecated (cfg config.Project ) map [string ]struct {} {
2313 deprecated := make (map [string ]struct {})
24- checkDeprecatedFields (reflect .ValueOf (cfg ).Elem (), "" , deprecated )
14+ checkDeprecatedFields (reflect .ValueOf (& cfg ).Elem (), "" , deprecated )
2515 return deprecated
2616}
2717
@@ -32,46 +22,45 @@ func checkDeprecatedFields(v reflect.Value, prefix string, deprecated map[string
3222 field := v .Field (i )
3323 fieldType := t .Field (i )
3424
35- // Skip unexported fields
3625 if ! field .CanInterface () {
3726 continue
3827 }
3928
40- // Get the yaml tag name
4129 yamlTag := fieldType .Tag .Get ("yaml" )
4230 if yamlTag == "" || yamlTag == "-" {
4331 continue
4432 }
45- // Remove omitempty and other options
33+
4634 yamlName := strings .Split (yamlTag , "," )[0 ]
4735
48- // Build the composed name
4936 var composedName string
5037 if prefix == "" {
5138 composedName = yamlName
5239 } else {
5340 composedName = prefix + "." + yamlName
5441 }
5542
56- // Check if field has "deprecated=true" in jsonschema tag
5743 isDeprecated := strings .Contains (fieldType .Tag .Get ("jsonschema" ), "deprecated" )
5844
59- // Check if the field is non-zero
6045 if isDeprecated && ! isZero (field ) {
6146 deprecated [composedName ] = struct {}{}
47+ continue
6248 }
6349
64- // Recursively check nested structs
6550 if field .Kind () == reflect .Struct {
6651 checkDeprecatedFields (field , composedName , deprecated )
67- } else if field .Kind () == reflect .Slice {
52+ continue
53+ }
54+ if field .Kind () == reflect .Slice {
6855 for j := 0 ; j < field .Len (); j ++ {
6956 elem := field .Index (j )
7057 if elem .Kind () == reflect .Struct {
7158 checkDeprecatedFields (elem , composedName , deprecated )
7259 }
7360 }
74- } else if field .Kind () == reflect .Pointer && ! field .IsNil () {
61+ continue
62+ }
63+ if field .Kind () == reflect .Pointer && ! field .IsNil () {
7564 if field .Elem ().Kind () == reflect .Struct {
7665 checkDeprecatedFields (field .Elem (), composedName , deprecated )
7766 }
0 commit comments