1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-29 12:58:29 +00:00

Always return the relevant status information, even if no status exists. (#35335)

This commit is contained in:
Lunny Xiao
2025-08-23 11:48:44 -07:00
committed by GitHub
parent 4b19e292b9
commit e1fd9e3cd1
2 changed files with 13 additions and 18 deletions

View File

@@ -42,20 +42,19 @@ func ToCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) [
}
// ToCombinedStatus converts List of CommitStatus to a CombinedStatus
func ToCombinedStatus(ctx context.Context, statuses []*git_model.CommitStatus, repo *api.Repository) *api.CombinedStatus {
if len(statuses) == 0 {
return nil
func ToCombinedStatus(ctx context.Context, commitID string, statuses []*git_model.CommitStatus, repo *api.Repository) *api.CombinedStatus {
status := api.CombinedStatus{
SHA: commitID,
TotalCount: len(statuses),
Repository: repo,
CommitURL: repo.URL + "/commits/" + url.PathEscape(commitID),
URL: repo.URL + "/commits/" + url.PathEscape(commitID) + "/status",
}
combinedStatus := git_model.CalcCommitStatus(statuses)
return &api.CombinedStatus{
State: combinedStatus.State,
Statuses: ToCommitStatuses(ctx, statuses),
SHA: combinedStatus.SHA,
TotalCount: len(statuses),
Repository: repo,
CommitURL: repo.URL + "/commits/" + url.PathEscape(combinedStatus.SHA),
URL: repo.URL + "/commits/" + url.PathEscape(combinedStatus.SHA) + "/status",
if combinedStatus != nil {
status.Statuses = ToCommitStatuses(ctx, statuses)
status.State = combinedStatus.State
}
return &status
}