File tree Expand file tree Collapse file tree 4 files changed +6
-23
lines changed
private/bufpkg/bufimage/bufimagemodify Expand file tree Collapse file tree 4 files changed +6
-23
lines changed Original file line number Diff line number Diff line change 22
33## [ Unreleased]
44
5- - No changes yet.
5+ - Fix default behavior for ` swift_prefix ` to remain unset when no override is provided in
6+ managed mode.
67
78## [ v1.62.0] - 2025-12-29
89
Original file line number Diff line number Diff line change @@ -99,7 +99,6 @@ func TestModifyImage(t *testing.T) {
9999 PhpMetadataNamespace : proto .String (`Foo\Empty_\GPBMetadata` ),
100100 PhpNamespace : proto .String (`Foo\Empty_` ),
101101 RubyPackage : proto .String ("Foo::Empty" ),
102- SwiftPrefix : proto .String ("Foo_Empty_" ),
103102 },
104103 "foo_empty/without_package.proto" : {
105104 // CcEnableArena's default value is true
@@ -126,7 +125,7 @@ func TestModifyImage(t *testing.T) {
126125 PhpNamespace : proto .String (`Bar\All` ),
127126 PyGenericServices : proto .Bool (false ),
128127 RubyPackage : proto .String ("Bar::All" ),
129- SwiftPrefix : proto .String ("Bar_All_ " ),
128+ SwiftPrefix : proto .String ("bar " ),
130129 },
131130 "bar_all/without_package.proto" : {
132131 CcEnableArenas : proto .Bool (true ),
Original file line number Diff line number Diff line change @@ -380,10 +380,10 @@ func modifySwiftPrefix(
380380 bufconfig .FileOptionUnspecified ,
381381 bufconfig .FileOptionUnspecified ,
382382 func (bufimage.ImageFile ) stringOverrideOptions {
383- return stringOverrideOptions {value : swiftPrefixValue ( imageFile ) }
383+ return stringOverrideOptions {}
384384 },
385- func (imageFile bufimage.ImageFile , _ stringOverrideOptions ) string {
386- return swiftPrefixValue ( imageFile )
385+ func (imageFile bufimage.ImageFile , stringOverrideOptions stringOverrideOptions ) string {
386+ return stringOverrideOptions . value
387387 },
388388 func (options * descriptorpb.FileOptions ) string {
389389 return options .GetSwiftPrefix ()
Original file line number Diff line number Diff line change @@ -422,20 +422,3 @@ func rubyPackageValue(imageFile bufimage.ImageFile) string {
422422 }
423423 return strings .Join (packageParts , "::" )
424424}
425-
426- // swiftPrefixValue returns the swift_prefix for the given ImageFile based on its
427- // package declaration. If the image file doesn't have a package declaration, an
428- // empty string is returned.
429- func swiftPrefixValue (imageFile bufimage.ImageFile ) string {
430- pkg := imageFile .FileDescriptorProto ().GetPackage ()
431- if pkg == "" {
432- return ""
433- }
434- packageParts := strings .Split (pkg , "." )
435- for i , part := range packageParts {
436- packageParts [i ] = xstrings .ToPascalCase (part )
437- }
438- // We add a "_" as the suffix since this emulates the default behavior if swift_prefix
439- // is not set.
440- return strings .Join (packageParts , "_" ) + "_"
441- }
You can’t perform that action at this time.
0 commit comments