0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-23 11:24:37 +01:00

Add MirrorUpdated field to Repository API type (#18267)

Add the last update time to the repository api type.

Close #18266
This commit is contained in:
Peter Gardfjäll 2022-01-18 14:18:30 +01:00 committed by GitHub
parent 68b59d8966
commit 89a3214352
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -5,6 +5,8 @@
package convert package convert
import ( import (
"time"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/perm" "code.gitea.io/gitea/models/perm"
@ -99,11 +101,13 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
numReleases, _ := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{IncludeDrafts: false, IncludeTags: false}) numReleases, _ := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{IncludeDrafts: false, IncludeTags: false})
mirrorInterval := "" mirrorInterval := ""
var mirrorUpdated time.Time
if repo.IsMirror { if repo.IsMirror {
var err error var err error
repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID) repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
if err == nil { if err == nil {
mirrorInterval = repo.Mirror.Interval.String() mirrorInterval = repo.Mirror.Interval.String()
mirrorUpdated = repo.Mirror.UpdatedUnix.AsTime()
} }
} }
@ -166,6 +170,7 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
AvatarURL: repo.AvatarLink(), AvatarURL: repo.AvatarLink(),
Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate, Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
MirrorInterval: mirrorInterval, MirrorInterval: mirrorInterval,
MirrorUpdated: mirrorUpdated,
RepoTransfer: transfer, RepoTransfer: transfer,
} }
} }

View file

@ -93,7 +93,9 @@ type Repository struct {
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
Internal bool `json:"internal"` Internal bool `json:"internal"`
MirrorInterval string `json:"mirror_interval"` MirrorInterval string `json:"mirror_interval"`
RepoTransfer *RepoTransfer `json:"repo_transfer"` // swagger:strfmt date-time
MirrorUpdated time.Time `json:"mirror_updated,omitempty"`
RepoTransfer *RepoTransfer `json:"repo_transfer"`
} }
// CreateRepoOption options when creating repository // CreateRepoOption options when creating repository

View file

@ -17195,6 +17195,11 @@
"type": "string", "type": "string",
"x-go-name": "MirrorInterval" "x-go-name": "MirrorInterval"
}, },
"mirror_updated": {
"type": "string",
"format": "date-time",
"x-go-name": "MirrorUpdated"
},
"name": { "name": {
"type": "string", "type": "string",
"x-go-name": "Name" "x-go-name": "Name"