diff options
-rw-r--r-- | integrations/pull_status_test.go | 2 | ||||
-rw-r--r-- | integrations/repo_commits_test.go | 6 | ||||
-rw-r--r-- | models/commit_status.go | 23 | ||||
-rw-r--r-- | modules/convert/convert.go | 21 | ||||
-rw-r--r-- | modules/convert/status.go | 56 | ||||
-rw-r--r-- | modules/gitgraph/graph_models.go | 2 | ||||
-rw-r--r-- | modules/structs/commit_status.go | 12 | ||||
-rw-r--r-- | modules/structs/status.go | 64 | ||||
-rw-r--r-- | routers/api/v1/repo/status.go | 54 | ||||
-rw-r--r-- | routers/api/v1/swagger/repo.go | 21 | ||||
-rw-r--r-- | routers/repo/blame.go | 2 | ||||
-rw-r--r-- | routers/repo/commit.go | 2 | ||||
-rw-r--r-- | routers/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/repo/view.go | 2 | ||||
-rw-r--r-- | services/pull/commit_status.go | 2 | ||||
-rw-r--r-- | services/pull/pull.go | 2 | ||||
-rw-r--r-- | templates/swagger/v1_json.tmpl | 272 |
17 files changed, 341 insertions, 206 deletions
diff --git a/integrations/pull_status_test.go b/integrations/pull_status_test.go index 0002784792..fc4c7ca33d 100644 --- a/integrations/pull_status_test.go +++ b/integrations/pull_status_test.go @@ -70,7 +70,7 @@ func TestPullCreate_CommitStatus(t *testing.T) { token := getTokenForLoggedInUser(t, session) req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/user1/repo1/statuses/%s?token=%s", commitID, token), api.CreateStatusOption{ - State: api.StatusState(status), + State: status, TargetURL: "http://test.ci/", Description: "", Context: "testci", diff --git a/integrations/repo_commits_test.go b/integrations/repo_commits_test.go index 2aa0260a16..f341f8026a 100644 --- a/integrations/repo_commits_test.go +++ b/integrations/repo_commits_test.go @@ -51,7 +51,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { // Call API to add status for commit req = NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/repo1/statuses/"+path.Base(commitURL)+"?token="+token, api.CreateStatusOption{ - State: api.StatusState(state), + State: api.CommitStatusState(state), TargetURL: "http://test.ci/", Description: "", Context: "testci", @@ -83,11 +83,11 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) { func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) { decoder := json.NewDecoder(resp.Body) - statuses := []*api.Status{} + statuses := []*api.CommitStatus{} assert.NoError(t, decoder.Decode(&statuses)) assert.Len(t, statuses, 1) for _, s := range statuses { - assert.Equal(t, api.StatusState(state), s.State) + assert.Equal(t, api.CommitStatusState(state), s.State) assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", s.URL) assert.Equal(t, "http://test.ci/", s.TargetURL) assert.Equal(t, "", s.Description) diff --git a/models/commit_status.go b/models/commit_status.go index 15fcbff6f9..9dffece378 100644 --- a/models/commit_status.go +++ b/models/commit_status.go @@ -38,7 +38,7 @@ type CommitStatus struct { UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } -func (status *CommitStatus) loadRepo(e Engine) (err error) { +func (status *CommitStatus) loadAttributes(e Engine) (err error) { if status.Repo == nil { status.Repo, err = getRepositoryByID(e, status.RepoID) if err != nil { @@ -56,7 +56,7 @@ func (status *CommitStatus) loadRepo(e Engine) (err error) { // APIURL returns the absolute APIURL to this commit-status. func (status *CommitStatus) APIURL() string { - _ = status.loadRepo(x) + _ = status.loadAttributes(x) return fmt.Sprintf("%sapi/v1/repos/%s/statuses/%s", setting.AppURL, status.Repo.FullName(), status.SHA) } @@ -139,13 +139,20 @@ func sortCommitStatusesSession(sess *xorm.Session, sortType string) { } // GetLatestCommitStatus returns all statuses with a unique context for a given commit. -func GetLatestCommitStatus(repo *Repository, sha string, page int) ([]*CommitStatus, error) { +func GetLatestCommitStatus(repoID int64, sha string, listOptions ListOptions) ([]*CommitStatus, error) { + return getLatestCommitStatus(x, repoID, sha, listOptions) +} + +func getLatestCommitStatus(e Engine, repoID int64, sha string, listOptions ListOptions) ([]*CommitStatus, error) { ids := make([]int64, 0, 10) - err := x.Limit(10, page*10). - Table(&CommitStatus{}). - Where("repo_id = ?", repo.ID).And("sha = ?", sha). + sess := e.Table(&CommitStatus{}). + Where("repo_id = ?", repoID).And("sha = ?", sha). Select("max( id ) as id"). - GroupBy("context_hash").OrderBy("max( id ) desc").Find(&ids) + GroupBy("context_hash").OrderBy("max( id ) desc") + + sess = listOptions.setSessionPagination(sess) + + err := sess.Find(&ids) if err != nil { return nil, err } @@ -261,7 +268,7 @@ func ParseCommitsWithStatus(oldCommits *list.List, repo *Repository) *list.List commit := SignCommitWithStatuses{ SignCommit: &c, } - statuses, err := GetLatestCommitStatus(repo, commit.ID.String(), 0) + statuses, err := GetLatestCommitStatus(repo.ID, commit.ID.String(), ListOptions{}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } else { diff --git a/modules/convert/convert.go b/modules/convert/convert.go index f9f4a641e2..63dd072fc4 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -347,27 +347,6 @@ func ToOAuth2Application(app *models.OAuth2Application) *api.OAuth2Application { } } -// ToCommitStatus converts models.CommitStatus to api.Status -func ToCommitStatus(status *models.CommitStatus) *api.Status { - apiStatus := &api.Status{ - Created: status.CreatedUnix.AsTime(), - Updated: status.CreatedUnix.AsTime(), - State: api.StatusState(status.State), - TargetURL: status.TargetURL, - Description: status.Description, - ID: status.Index, - URL: status.APIURL(), - Context: status.Context, - } - - if status.CreatorID != 0 { - creator, _ := models.GetUserByID(status.CreatorID) - apiStatus.Creator = ToUser(creator, false, false) - } - - return apiStatus -} - // ToLFSLock convert a LFSLock to api.LFSLock func ToLFSLock(l *models.LFSLock) *api.LFSLock { return &api.LFSLock{ diff --git a/modules/convert/status.go b/modules/convert/status.go new file mode 100644 index 0000000000..f972fc333c --- /dev/null +++ b/modules/convert/status.go @@ -0,0 +1,56 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package convert + +import ( + "code.gitea.io/gitea/models" + api "code.gitea.io/gitea/modules/structs" +) + +// ToCommitStatus converts models.CommitStatus to api.CommitStatus +func ToCommitStatus(status *models.CommitStatus) *api.CommitStatus { + apiStatus := &api.CommitStatus{ + Created: status.CreatedUnix.AsTime(), + Updated: status.CreatedUnix.AsTime(), + State: status.State, + TargetURL: status.TargetURL, + Description: status.Description, + ID: status.Index, + URL: status.APIURL(), + Context: status.Context, + } + + if status.CreatorID != 0 { + creator, _ := models.GetUserByID(status.CreatorID) + apiStatus.Creator = ToUser(creator, false, false) + } + + return apiStatus +} + +// ToCombinedStatus converts List of CommitStatus to a CombinedStatus +func ToCombinedStatus(statuses []*models.CommitStatus, repo *api.Repository) *api.CombinedStatus { + + if len(statuses) == 0 { + return nil + } + + retStatus := &api.CombinedStatus{ + SHA: statuses[0].SHA, + TotalCount: len(statuses), + Repository: repo, + URL: "", + } + + retStatus.Statuses = make([]*api.CommitStatus, 0, len(statuses)) + for _, status := range statuses { + retStatus.Statuses = append(retStatus.Statuses, ToCommitStatus(status)) + if status.State.NoBetterThan(retStatus.State) { + retStatus.State = status.State + } + } + + return retStatus +} diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go index ba168ab19d..2ae38188a6 100644 --- a/modules/gitgraph/graph_models.go +++ b/modules/gitgraph/graph_models.go @@ -113,7 +113,7 @@ func (graph *Graph) LoadAndProcessCommits(repository *models.Repository, gitRepo _ = models.CalculateTrustStatus(c.Verification, repository, &keyMap) - statuses, err := models.GetLatestCommitStatus(repository, c.Commit.ID.String(), 0) + statuses, err := models.GetLatestCommitStatus(repository.ID, c.Commit.ID.String(), models.ListOptions{}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } else { diff --git a/modules/structs/commit_status.go b/modules/structs/commit_status.go index 397356b133..23e0c383b8 100644 --- a/modules/structs/commit_status.go +++ b/modules/structs/commit_status.go @@ -4,20 +4,20 @@ package structs -// CommitStatusState holds the state of a Status +// CommitStatusState holds the state of a CommitStatus // It can be "pending", "success", "error", "failure", and "warning" type CommitStatusState string const ( - // CommitStatusPending is for when the Status is Pending + // CommitStatusPending is for when the CommitStatus is Pending CommitStatusPending CommitStatusState = "pending" - // CommitStatusSuccess is for when the Status is Success + // CommitStatusSuccess is for when the CommitStatus is Success CommitStatusSuccess CommitStatusState = "success" - // CommitStatusError is for when the Status is Error + // CommitStatusError is for when the CommitStatus is Error CommitStatusError CommitStatusState = "error" - // CommitStatusFailure is for when the Status is Failure + // CommitStatusFailure is for when the CommitStatus is Failure CommitStatusFailure CommitStatusState = "failure" - // CommitStatusWarning is for when the Status is Warning + // CommitStatusWarning is for when the CommitStatus is Warning CommitStatusWarning CommitStatusState = "warning" ) diff --git a/modules/structs/status.go b/modules/structs/status.go index e833bd69e5..ed42b24be8 100644 --- a/modules/structs/status.go +++ b/modules/structs/status.go @@ -8,32 +8,15 @@ import ( "time" ) -// StatusState holds the state of a Status -// It can be "pending", "success", "error", "failure", and "warning" -type StatusState string - -const ( - // StatusPending is for when the Status is Pending - StatusPending StatusState = "pending" - // StatusSuccess is for when the Status is Success - StatusSuccess StatusState = "success" - // StatusError is for when the Status is Error - StatusError StatusState = "error" - // StatusFailure is for when the Status is Failure - StatusFailure StatusState = "failure" - // StatusWarning is for when the Status is Warning - StatusWarning StatusState = "warning" -) - -// Status holds a single Status of a single Commit -type Status struct { - ID int64 `json:"id"` - State StatusState `json:"status"` - TargetURL string `json:"target_url"` - Description string `json:"description"` - URL string `json:"url"` - Context string `json:"context"` - Creator *User `json:"creator"` +// CommitStatus holds a single status of a single Commit +type CommitStatus struct { + ID int64 `json:"id"` + State CommitStatusState `json:"status"` + TargetURL string `json:"target_url"` + Description string `json:"description"` + URL string `json:"url"` + Context string `json:"context"` + Creator *User `json:"creator"` // swagger:strfmt date-time Created time.Time `json:"created_at"` // swagger:strfmt date-time @@ -42,24 +25,19 @@ type Status struct { // CombinedStatus holds the combined state of several statuses for a single commit type CombinedStatus struct { - State StatusState `json:"state"` - SHA string `json:"sha"` - TotalCount int `json:"total_count"` - Statuses []*Status `json:"statuses"` - Repository *Repository `json:"repository"` - CommitURL string `json:"commit_url"` - URL string `json:"url"` + State CommitStatusState `json:"state"` + SHA string `json:"sha"` + TotalCount int `json:"total_count"` + Statuses []*CommitStatus `json:"statuses"` + Repository *Repository `json:"repository"` + CommitURL string `json:"commit_url"` + URL string `json:"url"` } -// CreateStatusOption holds the information needed to create a new Status for a Commit +// CreateStatusOption holds the information needed to create a new CommitStatus for a Commit type CreateStatusOption struct { - State StatusState `json:"state"` - TargetURL string `json:"target_url"` - Description string `json:"description"` - Context string `json:"context"` -} - -// ListStatusesOption holds pagination information -type ListStatusesOption struct { - Page int + State CommitStatusState `json:"state"` + TargetURL string `json:"target_url"` + Description string `json:"description"` + Context string `json:"context"` } diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index 3b6d9b04c1..9c0d902f76 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -45,7 +45,7 @@ func NewCommitStatus(ctx *context.APIContext, form api.CreateStatusOption) { // "$ref": "#/definitions/CreateStatusOption" // responses: // "201": - // "$ref": "#/responses/Status" + // "$ref": "#/responses/CommitStatus" // "400": // "$ref": "#/responses/error" @@ -113,7 +113,7 @@ func GetCommitStatuses(ctx *context.APIContext) { // type: integer // responses: // "200": - // "$ref": "#/responses/StatusList" + // "$ref": "#/responses/CommitStatusList" // "400": // "$ref": "#/responses/error" @@ -165,7 +165,7 @@ func GetCommitStatusesByRef(ctx *context.APIContext) { // type: integer // responses: // "200": - // "$ref": "#/responses/StatusList" + // "$ref": "#/responses/CommitStatusList" // "400": // "$ref": "#/responses/error" @@ -221,7 +221,7 @@ func getCommitStatuses(ctx *context.APIContext, sha string) { return } - apiStatuses := make([]*api.Status, 0, len(statuses)) + apiStatuses := make([]*api.CommitStatus, 0, len(statuses)) for _, status := range statuses { apiStatuses = append(apiStatuses, convert.ToCommitStatus(status)) } @@ -233,19 +233,9 @@ func getCommitStatuses(ctx *context.APIContext, sha string) { ctx.JSON(http.StatusOK, apiStatuses) } -type combinedCommitStatus struct { - State api.CommitStatusState `json:"state"` - SHA string `json:"sha"` - TotalCount int `json:"total_count"` - Statuses []*api.Status `json:"statuses"` - Repo *api.Repository `json:"repository"` - CommitURL string `json:"commit_url"` - URL string `json:"url"` -} - // GetCombinedCommitStatusByRef returns the combined status for any given commit hash func GetCombinedCommitStatusByRef(ctx *context.APIContext) { - // swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/statuses repository repoGetCombinedStatusByRef + // swagger:operation GET /repos/{owner}/{repo}/commits/{ref}/status repository repoGetCombinedStatusByRef // --- // summary: Get a commit's combined status, by branch/tag/commit reference // produces: @@ -268,12 +258,15 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) { // required: true // - name: page // in: query - // description: page number of results + // description: page number of results to return (1-based) + // type: integer + // - name: limit + // in: query + // description: page size of results // type: integer - // required: false // responses: // "200": - // "$ref": "#/responses/Status" + // "$ref": "#/responses/CombinedStatus" // "400": // "$ref": "#/responses/error" @@ -284,33 +277,18 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) { } repo := ctx.Repo.Repository - page := ctx.QueryInt("page") - - statuses, err := models.GetLatestCommitStatus(repo, sha, page) + statuses, err := models.GetLatestCommitStatus(repo.ID, sha, utils.GetListOptions(ctx)) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s, %d]: %v", repo.FullName(), sha, page, err)) + ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s]: %v", repo.FullName(), sha, err)) return } if len(statuses) == 0 { - ctx.Status(http.StatusOK) + ctx.JSON(http.StatusOK, &api.CombinedStatus{}) return } - retStatus := &combinedCommitStatus{ - SHA: sha, - TotalCount: len(statuses), - Repo: convert.ToRepo(repo, ctx.Repo.AccessMode), - URL: "", - } - - retStatus.Statuses = make([]*api.Status, 0, len(statuses)) - for _, status := range statuses { - retStatus.Statuses = append(retStatus.Statuses, convert.ToCommitStatus(status)) - if status.State.NoBetterThan(retStatus.State) { - retStatus.State = status.State - } - } + combiStatus := convert.ToCombinedStatus(statuses, convert.ToRepo(repo, ctx.Repo.AccessMode)) - ctx.JSON(http.StatusOK, retStatus) + ctx.JSON(http.StatusOK, combiStatus) } diff --git a/routers/api/v1/swagger/repo.go b/routers/api/v1/swagger/repo.go index bce9e45c37..d539bcb9fe 100644 --- a/routers/api/v1/swagger/repo.go +++ b/routers/api/v1/swagger/repo.go @@ -169,18 +169,18 @@ type swaggerResponsePullReviewCommentList struct { Body []api.PullReviewComment `json:"body"` } -// Status -// swagger:response Status +// CommitStatus +// swagger:response CommitStatus type swaggerResponseStatus struct { // in:body - Body api.Status `json:"body"` + Body api.CommitStatus `json:"body"` } -// StatusList -// swagger:response StatusList -type swaggerResponseStatusList struct { +// CommitStatusList +// swagger:response CommitStatusList +type swaggerResponseCommitStatusList struct { // in:body - Body []api.Status `json:"body"` + Body []api.CommitStatus `json:"body"` } // WatchInfo @@ -309,3 +309,10 @@ type swaggerLanguageStatistics struct { // in: body Body map[string]int64 `json:"body"` } + +// CombinedStatus +// swagger:response CombinedStatus +type swaggerCombinedStatus struct { + // in: body + Body api.CombinedStatus `json:"body"` +} diff --git a/routers/repo/blame.go b/routers/repo/blame.go index bd11310988..514adc3bc1 100644 --- a/routers/repo/blame.go +++ b/routers/repo/blame.go @@ -87,7 +87,7 @@ func RefBlame(ctx *context.Context) { ctx.Data["LatestCommitVerification"] = models.ParseCommitWithSignature(latestCommit) ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit) - statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository, ctx.Repo.Commit.ID.String(), 0) + statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), models.ListOptions{}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 5bb26ffe41..43a95c2adb 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -296,7 +296,7 @@ func Diff(ctx *context.Context) { commitID = commit.ID.String() } - statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository, commitID, 0) + statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, commitID, models.ListOptions{}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 0ea6ec33de..bee3bbc1df 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -368,7 +368,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err) return nil } - commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0) + commitStatuses, err := models.GetLatestCommitStatus(repo.ID, sha, models.ListOptions{}) if err != nil { ctx.ServerError("GetLatestCommitStatus", err) return nil @@ -449,7 +449,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare return nil } - commitStatuses, err := models.GetLatestCommitStatus(repo, sha, 0) + commitStatuses, err := models.GetLatestCommitStatus(repo.ID, sha, models.ListOptions{}) if err != nil { ctx.ServerError("GetLatestCommitStatus", err) return nil diff --git a/routers/repo/view.go b/routers/repo/view.go index 7d69ee4cf8..66ad8e3ad7 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -353,7 +353,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["LatestCommitUser"] = models.ValidateCommitWithEmail(latestCommit) - statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository, ctx.Repo.Commit.ID.String(), 0) + statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, ctx.Repo.Commit.ID.String(), models.ListOptions{}) if err != nil { log.Error("GetLatestCommitStatus: %v", err) } diff --git a/services/pull/commit_status.go b/services/pull/commit_status.go index 592aad6fc5..b8fb109440 100644 --- a/services/pull/commit_status.go +++ b/services/pull/commit_status.go @@ -121,7 +121,7 @@ func GetPullRequestCommitStatusState(pr *models.PullRequest) (structs.CommitStat return "", errors.Wrap(err, "LoadBaseRepo") } - commitStatuses, err := models.GetLatestCommitStatus(pr.BaseRepo, sha, 0) + commitStatuses, err := models.GetLatestCommitStatus(pr.BaseRepo.ID, sha, models.ListOptions{}) if err != nil { return "", errors.Wrap(err, "GetLatestCommitStatus") } diff --git a/services/pull/pull.go b/services/pull/pull.go index 9cf4abfd54..f3fb762303 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -665,7 +665,7 @@ func GetLastCommitStatus(pr *models.PullRequest) (status *models.CommitStatus, e return nil, err } - statusList, err := models.GetLatestCommitStatus(pr.BaseRepo, lastCommitID, 0) + statusList, err := models.GetLatestCommitStatus(pr.BaseRepo.ID, lastCommitID, models.ListOptions{}) if err != nil { return nil, err } diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 6eb53a3d70..aa31b3f078 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -2867,7 +2867,7 @@ } } }, - "/repos/{owner}/{repo}/commits/{ref}/statuses": { + "/repos/{owner}/{repo}/commits/{ref}/status": { "get": { "produces": [ "application/json" @@ -2901,14 +2901,101 @@ }, { "type": "integer", - "description": "page number of results", + "description": "page number of results to return (1-based)", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "$ref": "#/responses/CombinedStatus" + }, + "400": { + "$ref": "#/responses/error" + } + } + } + }, + "/repos/{owner}/{repo}/commits/{ref}/statuses": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Get a commit's statuses, by branch/tag/commit reference", + "operationId": "repoListStatusesByRef", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of branch/tag/commit", + "name": "ref", + "in": "path", + "required": true + }, + { + "enum": [ + "oldest", + "recentupdate", + "leastupdate", + "leastindex", + "highestindex" + ], + "type": "string", + "description": "type of sort", + "name": "sort", + "in": "query" + }, + { + "enum": [ + "pending", + "success", + "error", + "failure", + "warning" + ], + "type": "string", + "description": "type of state", + "name": "state", + "in": "query" + }, + { + "type": "integer", + "description": "page number of results to return (1-based)", "name": "page", "in": "query" + }, + { + "type": "integer", + "description": "page size of results", + "name": "limit", + "in": "query" } ], "responses": { "200": { - "$ref": "#/responses/Status" + "$ref": "#/responses/CommitStatusList" }, "400": { "$ref": "#/responses/error" @@ -8462,7 +8549,7 @@ ], "responses": { "200": { - "$ref": "#/responses/StatusList" + "$ref": "#/responses/CommitStatusList" }, "400": { "$ref": "#/responses/error" @@ -8510,7 +8597,7 @@ ], "responses": { "201": { - "$ref": "#/responses/Status" + "$ref": "#/responses/CommitStatus" }, "400": { "$ref": "#/responses/error" @@ -11431,6 +11518,43 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CombinedStatus": { + "description": "CombinedStatus holds the combined state of several statuses for a single commit", + "type": "object", + "properties": { + "commit_url": { + "type": "string", + "x-go-name": "CommitURL" + }, + "repository": { + "$ref": "#/definitions/Repository" + }, + "sha": { + "type": "string", + "x-go-name": "SHA" + }, + "state": { + "$ref": "#/definitions/CommitStatusState" + }, + "statuses": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitStatus" + }, + "x-go-name": "Statuses" + }, + "total_count": { + "type": "integer", + "format": "int64", + "x-go-name": "TotalCount" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "Comment": { "description": "Comment represents a comment on a commit or issue", "type": "object", @@ -11558,6 +11682,55 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, + "CommitStatus": { + "description": "CommitStatus holds a single status of a single Commit", + "type": "object", + "properties": { + "context": { + "type": "string", + "x-go-name": "Context" + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "creator": { + "$ref": "#/definitions/User" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "ID" + }, + "status": { + "$ref": "#/definitions/CommitStatusState" + }, + "target_url": { + "type": "string", + "x-go-name": "TargetURL" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + }, + "url": { + "type": "string", + "x-go-name": "URL" + } + }, + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, + "CommitStatusState": { + "description": "CommitStatusState holds the state of a CommitStatus\nIt can be \"pending\", \"success\", \"error\", \"failure\", and \"warning\"", + "type": "string", + "x-go-package": "code.gitea.io/gitea/modules/structs" + }, "CommitUser": { "type": "object", "title": "CommitUser contains information of a user in the context of a commit.", @@ -12341,7 +12514,7 @@ "x-go-package": "code.gitea.io/gitea/modules/structs" }, "CreateStatusOption": { - "description": "CreateStatusOption holds the information needed to create a new Status for a Commit", + "description": "CreateStatusOption holds the information needed to create a new CommitStatus for a Commit", "type": "object", "properties": { "context": { @@ -12353,7 +12526,7 @@ "x-go-name": "Description" }, "state": { - "$ref": "#/definitions/StatusState" + "$ref": "#/definitions/CommitStatusState" }, "target_url": { "type": "string", @@ -15251,55 +15424,6 @@ "type": "string", "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "Status": { - "description": "Status holds a single Status of a single Commit", - "type": "object", - "properties": { - "context": { - "type": "string", - "x-go-name": "Context" - }, - "created_at": { - "type": "string", - "format": "date-time", - "x-go-name": "Created" - }, - "creator": { - "$ref": "#/definitions/User" - }, - "description": { - "type": "string", - "x-go-name": "Description" - }, - "id": { - "type": "integer", - "format": "int64", - "x-go-name": "ID" - }, - "status": { - "$ref": "#/definitions/StatusState" - }, - "target_url": { - "type": "string", - "x-go-name": "TargetURL" - }, - "updated_at": { - "type": "string", - "format": "date-time", - "x-go-name": "Updated" - }, - "url": { - "type": "string", - "x-go-name": "URL" - } - }, - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, - "StatusState": { - "description": "StatusState holds the state of a Status\nIt can be \"pending\", \"success\", \"error\", \"failure\", and \"warning\"", - "type": "string", - "x-go-package": "code.gitea.io/gitea/modules/structs" - }, "StopWatch": { "description": "StopWatch represent a running stopwatch", "type": "object", @@ -15773,6 +15897,12 @@ } } }, + "CombinedStatus": { + "description": "CombinedStatus", + "schema": { + "$ref": "#/definitions/CombinedStatus" + } + }, "Comment": { "description": "Comment", "schema": { @@ -15829,6 +15959,21 @@ } } }, + "CommitStatus": { + "description": "CommitStatus", + "schema": { + "$ref": "#/definitions/CommitStatus" + } + }, + "CommitStatusList": { + "description": "CommitStatusList", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/CommitStatus" + } + } + }, "ContentsListResponse": { "description": "ContentsListResponse", "schema": { @@ -16235,21 +16380,6 @@ "$ref": "#/definitions/ServerVersion" } }, - "Status": { - "description": "Status", - "schema": { - "$ref": "#/definitions/Status" - } - }, - "StatusList": { - "description": "StatusList", - "schema": { - "type": "array", - "items": { - "$ref": "#/definitions/Status" - } - } - }, "StopWatch": { "description": "StopWatch", "schema": { |