From e483220ea3c54137cec543842261f99c4696129a Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Fri, 18 Dec 2020 03:33:32 +0000
Subject: [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
---
 modules/structs/commit_status.go | 12 ++++----
 modules/structs/status.go        | 64 +++++++++++++---------------------------
 2 files changed, 27 insertions(+), 49 deletions(-)

(limited to 'modules/structs')

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"`
 }
-- 
cgit v1.2.3