fix: merge Forgejo pull requests by number

This commit is contained in:
eding 2026-07-26 20:58:27 +02:00
parent d9707a1f85
commit 189c79fad0
2 changed files with 3 additions and 3 deletions

View file

@ -42,7 +42,7 @@ type pullRequestRequest struct {
}
type pullRequest struct {
Index int `json:"index"`
Number int `json:"number"`
}
type mergePullRequestRequest struct {
@ -216,7 +216,7 @@ func (rm *RepoManager) MergePullRequest(repo, head string) error {
if err != nil {
return err
}
status, err = rm.apiRequest(http.MethodPost, fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/merge", rm.BaseURL, rm.Owner, repo, pullRequests[0].Index), body)
status, err = rm.apiRequest(http.MethodPost, fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/merge", rm.BaseURL, rm.Owner, repo, pullRequests[0].Number), body)
if err != nil {
return err
}

View file

@ -132,7 +132,7 @@ func TestMergePullRequest(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
switch request.Method {
case http.MethodGet:
_ = json.NewEncoder(writer).Encode([]pullRequest{{Index: 4}})
_ = json.NewEncoder(writer).Encode([]pullRequest{{Number: 4}})
case http.MethodPost:
var body mergePullRequestRequest
if err := json.NewDecoder(request.Body).Decode(&body); err != nil {