nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: googleapis/gapic-generator-go
Pull request #981 (2022-05-06 21:58:08)

fix(gengapic): REGAPIC fix path param parsing remove duped query param
When an HTTP path param encompassed multiple segements e.g. `{name=blah/blah}`, the `=blah/blah` portion wasn't stripped when attempting to look up the field, which resulted in it being considered a query param in addition to a path param.


Patch:
diff --git a/internal/gengapic/genrest.go b/internal/gengapic/genrest.go
index 08a37ab..f69e7c9 100644
--- a/internal/gengapic/genrest.go
+++ b/internal/gengapic/genrest.go
@@ -227,7 +227,7 @@ func (g *generator) pathParams(m *descriptor.MethodDescriptorProto) map[string]*
 		// In the returned slice, the zeroth element is the full regex match,
 		// and the subsequent elements are the sub group matches.
 		// See the docs for FindStringSubmatch for further details.
-		param := p[1]
+		param := strings.Split(p[1], "=")[0]
 		field := g.lookupField(m.GetInputType(), param)
 		if field == nil {
 			continue


Test patch:
diff --git a/internal/gengapic/testdata/rest_EmptyRPC.want b/internal/gengapic/testdata/rest_EmptyRPC.want
index a6d725c..43d1a88 100644
--- a/internal/gengapic/testdata/rest_EmptyRPC.want
+++ b/internal/gengapic/testdata/rest_EmptyRPC.want
@@ -6,9 +6,6 @@ func (c *fooRESTClient) EmptyRPC(ctx context.Context, req *foopb.Foo, opts ...ga
 	baseUrl.Path += fmt.Sprintf("/v1/foo/%v", req.GetOther())
 
 	params := url.Values{}
-	if req != nil && req.Other != nil {
-		params.Add("other", fmt.Sprintf("%v", req.GetOther()))
-	}
 	params.Add("size", fmt.Sprintf("%v", req.GetSize()))
 
 	baseUrl.RawQuery = params.Encode()
Repository: googleapis/gapic-generator-go
Pull request #1098 (2022-08-04 19:58:19)

fix(gengapic): fix linkParser regexp to support multi-line link tags
closes: #1097

quartzmo: @noahdietz Build error in compute-regen is:

```
[/home/runner/work/gapic-generator-go/gapic-generator-go] >>>> gofmt -s -d -w -l . <<<<
go: downloading github.com/googleapis/gax-go/v2 v2.5.0
go: downloading github.com/googleapis/gax-go v1.0.3
go: downloading golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c
go: downloading golang.org/x/net v0.0.0-20220802222814-0bcc04d9c69b
go: downloading google.golang.org/appengine v1.6.7
go: downloading golang.org/x/sys v0.0.0-20220804182731-e052cef7d300
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: loading module retractions for github.com/googleapis/gax-go/v2@v2.0.1: parsing go.mod: go.mod:8:2: require google.golang.org/genproto: version "b98a9ff5e252" invalid: must be of the form v1.2.3
Error: Process completed with exit code 1.
```

Any suggestions?
noahdietz: @quartzmo uh oh...I think that means a bad pseudo-version was introduced into a go.mod/sum, but I'm not sure...I will look at it.

Patch:
diff --git a/internal/gengapic/markdown.go b/internal/gengapic/markdown.go
index 0b00bfd..97be4f1 100644
--- a/internal/gengapic/markdown.go
+++ b/internal/gengapic/markdown.go
@@ -26,7 +26,7 @@ import (
 	"gitlab.com/golang-commonmark/markdown"
 )
 
-var linkParser = regexp.MustCompile(`<a href=["'](.+)["']`)
+var linkParser = regexp.MustCompile(`<a\s+href=["'](.+)["']`)
 var referenceParser = regexp.MustCompile(`\[([a-zA-Z1-9._]+)\]\[[a-zA-Z1-9._]*\]`)
 
 func mdPlain(s string) string {


Test patch:
diff --git a/internal/gengapic/markdown_test.go b/internal/gengapic/markdown_test.go
index af112a9..ba5d042 100644
--- a/internal/gengapic/markdown_test.go
+++ b/internal/gengapic/markdown_test.go
@@ -73,6 +73,10 @@ func TestMDPlain(t *testing.T) {
 			in:   "html <a href=\"/link/to/some#thing\">\n with a softbreak</a> <br> test",
 			want: "html with a softbreak (at /link/to/some#thing) \n test",
 		},
+		{
+			in:   "html <a \n  href=\"/link/to/some#thing\">\n with a linebreak in tag</a> <br> test",
+			want: "html with a linebreak in tag (at /link/to/some#thing) \n test",
+		},
 		{
 			in:   "link to [a search engine](https://www.google.com) with request type [Search][foo.bar_baz.v1.Search], [biz][][buz][baz].",
 			want: "link to a search engine (at https://www.google.com) with request type Search, bizbuz.",
Repository: googleapis/gapic-generator-go
Pull request #1181 (2022-11-08 22:29:05)

fix(gengapic): document client/bidi streaming unsupported in REST
Generate interface-level, method documentation for Client and Bi-Di streaming methods when `rest` transport is selected that indicates that the method is unsupported for the REST transport. This should help reduce confusion when the method returns an error saying the same thing.

Note: `m.GetClientStreaming()` covers both streaming types in scope becaus Bi-Di stream is just `ClientStreaming: true` && `ServerStreaming: true`.


Patch:
diff --git a/internal/gengapic/gengapic.go b/internal/gengapic/gengapic.go
index ea961d6..0c65309 100644
--- a/internal/gengapic/gengapic.go
+++ b/internal/gengapic/gengapic.go
@@ -479,6 +479,9 @@ func (g *generator) methodDoc(m *descriptor.MethodDescriptorProto) {
 		return
 	}
 
+	if containsTransport(g.opts.transports, rest) && m.GetClientStreaming() {
+		com = fmt.Sprintf("%s\n\nThis method is not supported for the REST transport.", com)
+	}
 	// If the method is marked as deprecated and there is no comment, then add default deprecation comment.
 	// If the method has a comment but it does not include a deprecation notice, then append a default deprecation notice.
 	// If the method includes a deprecation notice at the beginning of the comment, prepend a comment stating the method is deprecated and use the included deprecation notice.


Test patch:
diff --git a/internal/gengapic/gengapic_test.go b/internal/gengapic/gengapic_test.go
index 2015960..fc422f1 100644
--- a/internal/gengapic/gengapic_test.go
+++ b/internal/gengapic/gengapic_test.go
@@ -564,8 +564,9 @@ func TestMethodDoc(t *testing.T) {
 	}
 
 	for _, tst := range []struct {
-		in, want   string
-		deprecated bool
+		in, want                    string
+		clientStreaming, deprecated bool
+		opts                        options
 	}{
 		{
 			in:   "",
@@ -595,11 +596,19 @@ func TestMethodDoc(t *testing.T) {
 			want:       "// MyMethod is deprecated.\n//\n// Deprecated: MyMethod may be removed in a future version.\n",
 			deprecated: true,
 		},
+		{
+			in:              "Does client streaming stuff.\n It also does other stuffs.",
+			want:            "// MyMethod does client streaming stuff.\n// It also does other stuffs.\n//\n// This method is not supported for the REST transport.\n",
+			clientStreaming: true,
+			opts:            options{transports: []transport{rest}},
+		},
 	} {
+		g.opts = &tst.opts
 		g.comments[m] = tst.in
 		m.Options = &descriptor.MethodOptions{
 			Deprecated: proto.Bool(tst.deprecated),
 		}
+		m.ClientStreaming = proto.Bool(tst.clientStreaming)
 		g.pt.Reset()
 		g.methodDoc(m)
 		if diff := cmp.Diff(g.pt.String(), tst.want); diff != "" {
Repository: googleapis/gapic-generator-go
Pull request #1202 (2022-12-19 20:06:29)

fix(gengapic): inject gRPC server stream call opts
Inject default call options for server-stream, gRPC calls. This includes default retry options that will work when trying to establish a new stream.

It looks like, unfortunately, this was errantly removed in #577 and it snuck through review.

Addresses the generator issue mentioned in https://github.com/googleapis/google-cloud-go/issues/5906.


Patch:
diff --git a/internal/gengapic/stream.go b/internal/gengapic/stream.go
index 27733ac..ccd5183 100644
--- a/internal/gengapic/stream.go
+++ b/internal/gengapic/stream.go
@@ -72,6 +72,7 @@ func (g *generator) serverStreamCall(servName string, s *descriptor.ServiceDescr
 		lowcaseServName, m.GetName(), inSpec.Name, inType.GetName(), servSpec.Name, s.GetName(), m.GetName())
 
 	g.insertRequestHeaders(m, grpc)
+	g.appendCallOpts(m)
 
 	p("  var resp %s.%s_%sClient", servSpec.Name, s.GetName(), m.GetName())
 	p("err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {")


Test patch:
diff --git a/internal/gengapic/testdata/method_ServerThings.want b/internal/gengapic/testdata/method_ServerThings.want
index dd8752d..b6172de 100644
--- a/internal/gengapic/testdata/method_ServerThings.want
+++ b/internal/gengapic/testdata/method_ServerThings.want
@@ -2,6 +2,7 @@ func (c *fooGRPCClient) ServerThings(ctx context.Context, req *mypackagepb.Input
 	md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v&%s=%v&%s=%v&%s=%v&%s=%v&%s=%v", "field_name.nested", url.QueryEscape(req.GetFieldName().GetNested()), "other", url.QueryEscape(req.GetOther()), "another", url.QueryEscape(req.GetAnother()), "biz", url.QueryEscape(fmt.Sprintf("%g", req.GetBiz())), "top_level_enum", mypackagepb.TopLevelEnum_name[int32(req.GetTopLevelEnum())], "nested_enum", mypackagepb.InputType_NestedEnum_name[int32(req.GetNestedEnum())]))
 
 	ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+	opts = append((*c.CallOptions).ServerThings[0:len((*c.CallOptions).ServerThings):len((*c.CallOptions).ServerThings)], opts...)
 	var resp mypackagepb.Foo_ServerThingsClient
 	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
 		var err error