nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: elixir-protobuf/protobuf
Pull request #151 (2021-04-17 13:10:40)

Upgrade Elixir from 1.11.2 to 1.11.4 in GitHub workflow


Patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c20aeac..a63fa2d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ jobs:
       matrix:
         include:
           - otp: 23.0
-            elixir: 1.11.2
+            elixir: 1.11.4
             lint: true
           - otp: 23.0
             elixir: 1.10.3
diff --git a/lib/protobuf/protoc/generator/message.ex b/lib/protobuf/protoc/generator/message.ex
index a53cb18..821bea1 100644
--- a/lib/protobuf/protoc/generator/message.ex
+++ b/lib/protobuf/protoc/generator/message.ex
@@ -115,6 +115,7 @@ defmodule Protobuf.Protoc.Generator.Message do
         {fmt_type_name(f.name, longest_width), "{atom, any}"}
       end)
 
+
     types =
       types ++
         Enum.map(fields, fn f ->
@@ -153,7 +154,7 @@ defmodule Protobuf.Protoc.Generator.Message do
   end
 
   defp fmt_type(%{label: "repeated", type_enum: type_enum, type: type}) do
-    "[#{type_to_spec(type_enum, type, true)}]"
+    type_to_spec(type_enum, type, true)
   end
 
   defp fmt_type(%{type_enum: type_enum, type: type}) do
diff --git a/lib/protobuf/type_util.ex b/lib/protobuf/type_util.ex
index d6db5f2..8057623 100644
--- a/lib/protobuf/type_util.ex
+++ b/lib/protobuf/type_util.ex
@@ -36,7 +36,7 @@ defmodule Protobuf.TypeUtil do
   def enum_to_spec(:TYPE_SINT32), do: "integer"
   def enum_to_spec(:TYPE_SINT64), do: "integer"
   def enum_to_spec(_), do: "any"
-  def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "#{type}.t"
+  def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "[#{type}.t]"
   def enum_to_spec(:TYPE_MESSAGE, type, false = _repeated), do: "#{type}.t | nil"
   def enum_to_spec(:TYPE_ENUM, type, true = _repeated), do: "[#{type}.t]"
   def enum_to_spec(:TYPE_ENUM, type, false = _repeated), do: "#{type}.t"


Test patch:
diff --git a/test/protobuf/protoc/generator/message_test.exs b/test/protobuf/protoc/generator/message_test.exs
index 079e0f1..c4e9e8c 100644
--- a/test/protobuf/protoc/generator/message_test.exs
+++ b/test/protobuf/protoc/generator/message_test.exs
@@ -515,4 +515,31 @@ defmodule Protobuf.Protoc.Generator.MessageTest do
       assert msg =~ "field :the_field_name, 1, required: true, type: :string\n"
     end
   end
+
+  test "generate/2 repeated enum field in typespec" do
+    ctx = %Context{
+      package: "foo_bar.ab_cd",
+      dep_type_mapping: %{
+        ".foo_bar.ab_cd.EnumFoo" => %{type_name: "FooBar.AbCd.EnumFoo"}
+      }
+    }
+
+    desc =
+      Google.Protobuf.DescriptorProto.new(
+        name: "Foo",
+        field: [
+          Google.Protobuf.FieldDescriptorProto.new(
+            name: "a",
+            json_name: "a",
+            number: 1,
+            type: :TYPE_ENUM,
+            label: :LABEL_REPEATED,
+            type_name: ".foo_bar.ab_cd.EnumFoo"
+          )
+        ]
+      )
+
+    {[], [msg]} = Generator.generate(ctx, desc)
+    assert msg =~ "a: [FooBar.AbCd.EnumFoo.t]"
+  end
 end