summaryrefslogtreecommitdiffstats
path: root/modules/structs/status.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-12-18 03:33:32 +0000
committerGitHub <noreply@github.com>2020-12-18 11:33:32 +0800
commite483220ea3c54137cec543842261f99c4696129a (patch)
tree2f81f173315b8ebe92403290977c09bfc32bf754 /modules/structs/status.go
parent27edc1aa19afb043a497a7dc628afa420cb1de55 (diff)
downloadgitea-e483220ea3c54137cec543842261f99c4696129a.tar.gz
gitea-e483220ea3c54137cec543842261f99c4696129a.zip
[Refactor] CombinedStatus and CommitStatus related functions & structs (#14026)
* RM unused struct * rename (*CommitStatus) loadRepo() -> loadAttributes() * move ToCommitStatus into its own file * use CommitStatusState instead of StatusState * move CombinedStatus convertion into convert package * let models.GetLatestCommitStatus use repoID direct and accept ListOptions * update swagger docs * fix tests * Fix swagger docs * rm page * fix swagger docs!!! * return json null * always return json * rename api.Status to api.CommitStatus * fix swagger docs * sec swagger fix
Diffstat (limited to 'modules/structs/status.go')
-rw-r--r--modules/structs/status.go64
1 files changed, 21 insertions, 43 deletions
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"`
}