nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: xanzy/go-gitlab
Pull request #935 (2020-09-08 11:09:57)

Add missing attributes to SetCommitStatus API
Add a the ability to set a couple of missing attributes in the SetCommitStatus API call


Patch:
diff --git a/commits.go b/commits.go
index f9c6f8c..c2b8dd5 100644
--- a/commits.go
+++ b/commits.go
@@ -446,6 +446,8 @@ type SetCommitStatusOptions struct {
 	Context     *string         `url:"context,omitempty" json:"context,omitempty"`
 	TargetURL   *string         `url:"target_url,omitempty" json:"target_url,omitempty"`
 	Description *string         `url:"description,omitempty" json:"description,omitempty"`
+	Coverage    *float64        `url:"coverage,omitempty" json:"coverage,omitempty"`
+	PipelineID  *int            `url:"pipeline_id,omitempty" json:"pipeline_id,omitempty"`
 }
 
 // SetCommitStatus sets the status of a commit in a project.


Test patch:
diff --git a/commits_test.go b/commits_test.go
index e68388a..bca6eaa 100644
--- a/commits_test.go
+++ b/commits_test.go
@@ -1,7 +1,10 @@
 package gitlab
 
 import (
+	"encoding/json"
 	"fmt"
+	"github.com/stretchr/testify/require"
+	"io/ioutil"
 	"net/http"
 	"reflect"
 	"testing"
@@ -83,10 +86,21 @@ func TestSetCommitStatus(t *testing.T) {
 
 	mux.HandleFunc("/api/v4/projects/1/statuses/b0b3a907f41409829b307a28b82fdbd552ee5a27", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "POST")
+		body, err := ioutil.ReadAll(r.Body)
+		require.NoError(t, err)
+
+		var content SetCommitStatusOptions
+		err = json.Unmarshal(body, &content)
+		require.NoError(t, err)
+
+		assert.Equal(t, "ci/jenkins", *content.Name)
+		assert.Equal(t, 99.9, *content.Coverage)
 		fmt.Fprint(w, `{"id":1}`)
 	})
 
-	opt := &SetCommitStatusOptions{State: Running, Ref: String("master"), Name: String("ci/jenkins"), Context: String(""), TargetURL: String("http://abc"), Description: String("build")}
+	cov := 99.9
+	opt := &SetCommitStatusOptions{State: Running, Ref: String("master"), Name: String("ci/jenkins"),
+		Context: String(""), TargetURL: String("http://abc"), Description: String("build"), Coverage: &cov}
 	status, _, err := client.Commits.SetCommitStatus("1", "b0b3a907f41409829b307a28b82fdbd552ee5a27", opt)
 
 	if err != nil {
Repository: xanzy/go-gitlab
Pull request #936 (2020-09-08 16:51:33)

Add WebURL to users.
Adds the missing field to User.

https://docs.gitlab.com/ee/api/users.html#single-user


Patch:
diff --git a/users.go b/users.go
index 2b5a992..9a220b8 100644
--- a/users.go
+++ b/users.go
@@ -59,6 +59,7 @@ type User struct {
 	Email                     string             `json:"email"`
 	Name                      string             `json:"name"`
 	State                     string             `json:"state"`
+	WebURL                    string             `json:"web_url"`
 	CreatedAt                 *time.Time         `json:"created_at"`
 	Bio                       string             `json:"bio"`
 	Location                  string             `json:"location"`


Test patch:
diff --git a/search_test.go b/search_test.go
index 80c1d1f..c8d67ff 100644
--- a/search_test.go
+++ b/search_test.go
@@ -27,6 +27,7 @@ func TestSearchService_Users(t *testing.T) {
 		Name:      "John Doe1",
 		State:     "active",
 		AvatarURL: "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
+		WebURL:    "http://localhost/user1",
 	}}
 	require.Equal(t, want, users)
 }
@@ -51,6 +52,7 @@ func TestSearchService_UsersByGroup(t *testing.T) {
 		Name:      "John Doe1",
 		State:     "active",
 		AvatarURL: "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
+		WebURL:    "http://localhost/user1",
 	}}
 	require.Equal(t, want, users)
 }
@@ -75,6 +77,7 @@ func TestSearchService_UsersByProject(t *testing.T) {
 		Name:      "John Doe1",
 		State:     "active",
 		AvatarURL: "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
+		WebURL:    "http://localhost/user1",
 	}}
 	require.Equal(t, want, users)
 }
Repository: xanzy/go-gitlab
Pull request #988 (2020-11-29 06:22:55)

Adds IssueEvent Description and Title changes
Undocumented, but exists in events.


Patch:
diff --git a/event_webhook_types.go b/event_webhook_types.go
index 39778c6..eb74b1d 100644
--- a/event_webhook_types.go
+++ b/event_webhook_types.go
@@ -175,10 +175,18 @@ type IssueEvent struct {
 	} `json:"assignees"`
 	Labels  []Label `json:"labels"`
 	Changes struct {
+		Description struct {
+			Previous string `json:"previous"`
+			Current  string `json:"current"`
+		} `json:"description"`
 		Labels struct {
 			Previous []Label `json:"previous"`
 			Current  []Label `json:"current"`
 		} `json:"labels"`
+		Title struct {
+			Previous string `json:"previous"`
+			Current  string `json:"current"`
+		} `json:"title"`
 		UpdatedByID struct {
 			Previous int `json:"previous"`
 			Current  int `json:"current"`


Test patch:
diff --git a/event_parsing_webhook_test.go b/event_parsing_webhook_test.go
index e738564..cd3e15a 100644
--- a/event_parsing_webhook_test.go
+++ b/event_parsing_webhook_test.go
@@ -117,6 +117,10 @@ func TestParseIssueHook(t *testing.T) {
 	assert.Equal(t, 1, event.Changes.UpdatedByID.Current)
 	assert.Equal(t, 1, len(event.Changes.Labels.Previous))
 	assert.Equal(t, 1, len(event.Changes.Labels.Current))
+	assert.Equal(t, "", event.Changes.Description.Previous)
+	assert.Equal(t, "New description", event.Changes.Description.Current)
+	assert.Equal(t, "", event.Changes.Title.Previous)
+	assert.Equal(t, "New title", event.Changes.Title.Current)
 }
 
 func TestParseCommitCommentHook(t *testing.T) {
diff --git a/testdata/webhooks/issue.json b/testdata/webhooks/issue.json
index 0dbfcc5..1f38d45 100644
--- a/testdata/webhooks/issue.json
+++ b/testdata/webhooks/issue.json
@@ -102,6 +102,14 @@
         "type": "ProjectLabel",
         "group_id": 41
       }]
+    },
+    "description": {
+      "previous": null,
+      "current": "New description"
+    },
+    "title": {
+      "previous": null,
+      "current": "New title"
     }
   }
 }
Repository: xanzy/go-gitlab
Pull request #1012 (2020-12-21 08:38:11)

Delete Runner by ID


Patch:
diff --git a/runners.go b/runners.go
index 58e8ef1..4e7a6db 100644
--- a/runners.go
+++ b/runners.go
@@ -419,10 +419,10 @@ type DeleteRegisteredRunnerOptions struct {
 	Token *string `url:"token" json:"token"`
 }
 
-// DeleteRegisteredRunner registers a new Runner for the instance.
+// DeleteRegisteredRunner deletes a Runner by Token.
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ce/api/runners.html#delete-a-registered-runner
+// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-authentication-token
 func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptions, options ...RequestOptionFunc) (*Response, error) {
 	req, err := s.client.NewRequest("DELETE", "runners", opt, options)
 	if err != nil {
@@ -432,6 +432,19 @@ func (s *RunnersService) DeleteRegisteredRunner(opt *DeleteRegisteredRunnerOptio
 	return s.client.Do(req, nil)
 }
 
+// DeleteRegisteredRunnerByID deletes a Runner by ID.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ce/api/runners.html#delete-a-runner-by-id
+func (s *RunnersService) DeleteRegisteredRunnerByID(rid int, options ...RequestOptionFunc) (*Response, error) {
+	req, err := s.client.NewRequest("DELETE", fmt.Sprintf("runners/%d", rid), nil, options)
+	if err != nil {
+		return nil, err
+	}
+
+	return s.client.Do(req, nil)
+}
+
 // VerifyRegisteredRunnerOptions represents the available
 // VerifyRegisteredRunner() options.
 //


Test patch:
diff --git a/runners_test.go b/runners_test.go
index 4890002..af39565 100644
--- a/runners_test.go
+++ b/runners_test.go
@@ -248,6 +248,28 @@ func TestDeleteRegisteredRunner(t *testing.T) {
 	}
 }
 
+func TestDeleteRegisteredRunnerByID(t *testing.T) {
+	mux, server, client := setup(t)
+	defer teardown(server)
+
+	mux.HandleFunc("/api/v4/runners/11111", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+		w.WriteHeader(http.StatusNoContent)
+	})
+
+	rid := 11111
+
+	resp, err := client.Runners.DeleteRegisteredRunnerByID(rid, nil)
+	if err != nil {
+		t.Fatalf("Runners.DeleteRegisteredRunnerByID returns an error: %v", err)
+	}
+
+	want := 204
+	if !reflect.DeepEqual(want, resp.StatusCode) {
+		t.Errorf("Runners.DeleteRegisteredRunnerByID returned returned status code  %+v, want %+v", resp.StatusCode, want)
+	}
+}
+
 func TestVerifyRegisteredRunner(t *testing.T) {
 	mux, server, client := setup(t)
 	defer teardown(server)