Change PullRequest Index to ForgeRemoteID / string type (#2823)

Co-authored-by: Patrick Schratz <patrick.schratz@gmail.com>
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
Michalis Zampetakis 2023-11-26 01:52:52 +02:00 committed by GitHub
parent 418acc5c98
commit 981384b79a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 12 additions and 11 deletions

View file

@ -4047,7 +4047,7 @@ const docTemplate = `{
"type": "object",
"properties": {
"index": {
"type": "integer"
"type": "string"
},
"title": {
"type": "string"

View file

@ -21,6 +21,7 @@ import (
"net/http"
"net/url"
"path/filepath"
"strconv"
"golang.org/x/oauth2"
@ -369,7 +370,7 @@ func (c *config) PullRequests(ctx context.Context, u *model.User, r *model.Repo,
result := []*model.PullRequest{}
for _, pullRequest := range pullRequests {
result = append(result, &model.PullRequest{
Index: int64(pullRequest.ID),
Index: model.ForgeRemoteID(strconv.Itoa(int(pullRequest.ID))),
Title: pullRequest.Title,
})
}

View file

@ -200,7 +200,7 @@ func Test_bitbucket(t *testing.T) {
repoPRs, err := c.PullRequests(ctx, fakeUser, fakeRepo, &listOpts)
g.Assert(err).IsNil()
g.Assert(repoPRs[0].Title).Equal("PRs title")
g.Assert(repoPRs[0].Index).Equal(int64(123))
g.Assert(repoPRs[0].Index).Equal(model.ForgeRemoteID("123"))
})
g.It("Should handle not found errors", func() {
_, err := c.PullRequests(ctx, fakeUser, fakeRepoNotFound, &listOpts)

View file

@ -488,7 +488,7 @@ func (c *Gitea) PullRequests(ctx context.Context, u *model.User, r *model.Repo,
result := make([]*model.PullRequest, len(pullRequests))
for i := range pullRequests {
result[i] = &model.PullRequest{
Index: pullRequests[i].Index,
Index: model.ForgeRemoteID(strconv.Itoa(int(pullRequests[i].Index))),
Title: pullRequests[i].Title,
}
}

View file

@ -296,7 +296,7 @@ func (c *client) PullRequests(ctx context.Context, u *model.User, r *model.Repo,
result := make([]*model.PullRequest, len(pullRequests))
for i := range pullRequests {
result[i] = &model.PullRequest{
Index: int64(pullRequests[i].GetNumber()),
Index: model.ForgeRemoteID(strconv.Itoa(pullRequests[i].GetNumber())),
Title: pullRequests[i].GetTitle(),
}
}

View file

@ -326,7 +326,7 @@ func (g *GitLab) PullRequests(ctx context.Context, u *model.User, r *model.Repo,
result := make([]*model.PullRequest, len(pullRequests))
for i := range pullRequests {
result[i] = &model.PullRequest{
Index: int64(pullRequests[i].ID),
Index: model.ForgeRemoteID(strconv.Itoa(pullRequests[i].ID)),
Title: pullRequests[i].Title,
}
}

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.36.1. DO NOT EDIT.
// Code generated by mockery v2.37.1. DO NOT EDIT.
package mocks

View file

@ -15,6 +15,6 @@
package model
type PullRequest struct {
Index int64 `json:"index"`
Title string `json:"title"`
Index ForgeRemoteID `json:"index"`
Title string `json:"title"`
} // @name PullRequest

View file

@ -1,4 +1,4 @@
// Code generated by mockery v2.36.1. DO NOT EDIT.
// Code generated by mockery v2.37.1. DO NOT EDIT.
package mocks

View file

@ -1,7 +1,7 @@
// A version control pull request.
export type PullRequest = {
// The index of the pull request.
index: number;
index: string;
// The title of the pull request.
title: string;
};