staging: use status line in PRs
This commit is contained in:
@@ -124,18 +124,12 @@ const (
|
||||
CommitStatus_Error = "error"
|
||||
)
|
||||
|
||||
type CommitStatus struct {
|
||||
Context string
|
||||
Description string
|
||||
CommitStatus string
|
||||
}
|
||||
|
||||
type GiteaCommitStatusSetter interface {
|
||||
SetCommitStatus(org, repo, hash string, status *CommitStatus) error
|
||||
SetCommitStatus(org, repo, hash string, status *models.CommitStatus) (*models.CommitStatus, error)
|
||||
}
|
||||
|
||||
type GiteaCommitStatusGetter interface {
|
||||
GetCommitStatus(org, repo, hash string) ([]*CommitStatus, error)
|
||||
GetCommitStatus(org, repo, hash string) ([]*models.CommitStatus, error)
|
||||
}
|
||||
|
||||
type Gitea interface {
|
||||
@@ -148,6 +142,8 @@ type Gitea interface {
|
||||
GiteaCommentFetcher
|
||||
GiteaMaintainershipReader
|
||||
GiteaFileContentReader
|
||||
GiteaCommitStatusGetter
|
||||
GiteaCommitStatusSetter
|
||||
|
||||
GetPullNotifications(since *time.Time) ([]*models.NotificationThread, error)
|
||||
SetNotificationRead(notificationId int64) error
|
||||
@@ -205,6 +201,47 @@ func (gitea *GiteaTransport) GetPullRequest(org, project string, num int64) (*mo
|
||||
return pr.Payload, err
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetCommitStatus(org, repo, hash string) ([]*models.CommitStatus, error) {
|
||||
page := int64(1)
|
||||
limit := int64(10)
|
||||
var res []*models.CommitStatus
|
||||
|
||||
for {
|
||||
r, err := gitea.client.Repository.RepoListStatuses(
|
||||
repository.NewRepoListStatusesParams().WithDefaults().WithOwner(org).WithRepo(repo).WithSha(hash).WithPage(&page).WithLimit(&limit),
|
||||
gitea.transport.DefaultAuthentication)
|
||||
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
res = append(res, r.Payload...)
|
||||
if len(r.Payload) < int(limit) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) SetCommitStatus(org, repo, hash string, status *models.CommitStatus) (*models.CommitStatus, error) {
|
||||
res, err := gitea.client.Repository.RepoCreateStatus(
|
||||
repository.NewRepoCreateStatusParams().
|
||||
WithDefaults().
|
||||
WithOwner(org).
|
||||
WithRepo(repo).
|
||||
WithSha(hash).
|
||||
WithBody(&models.CreateStatusOption{
|
||||
TargetURL: status.TargetURL,
|
||||
Description: status.Description,
|
||||
Context: status.Context,
|
||||
State: models.CommitStatusState(status.Status),
|
||||
}),
|
||||
gitea.transport.DefaultAuthentication,
|
||||
)
|
||||
return res.Payload, err
|
||||
}
|
||||
|
||||
func (gitea *GiteaTransport) GetRepository(org, pkg string) (*models.Repository, error) {
|
||||
repo, err := gitea.client.Repository.RepoGet(repository.NewRepoGetParams().WithDefaults().WithOwner(org).WithRepo(pkg), gitea.transport.DefaultAuthentication)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user