Skip to content

Commit 388fbb1

Browse files
petergardfjallStelios Malathouras
authored and
Stelios Malathouras
committed
Add MirrorUpdated field to Repository API type (go-gitea#18267)
Add the last update time to the repository api type. Close go-gitea#18266
1 parent 9e14ee7 commit 388fbb1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

modules/convert/repository.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package convert
66

77
import (
8+
"time"
9+
810
"code.gitea.io/gitea/models"
911
"code.gitea.io/gitea/models/db"
1012
"code.gitea.io/gitea/models/perm"
@@ -99,11 +101,13 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
99101
numReleases, _ := models.GetReleaseCountByRepoID(repo.ID, models.FindReleasesOptions{IncludeDrafts: false, IncludeTags: false})
100102

101103
mirrorInterval := ""
104+
var mirrorUpdated time.Time
102105
if repo.IsMirror {
103106
var err error
104107
repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
105108
if err == nil {
106109
mirrorInterval = repo.Mirror.Interval.String()
110+
mirrorUpdated = repo.Mirror.UpdatedUnix.AsTime()
107111
}
108112
}
109113

@@ -166,6 +170,7 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
166170
AvatarURL: repo.AvatarLink(),
167171
Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
168172
MirrorInterval: mirrorInterval,
173+
MirrorUpdated: mirrorUpdated,
169174
RepoTransfer: transfer,
170175
}
171176
}

modules/structs/repo.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ type Repository struct {
9393
AvatarURL string `json:"avatar_url"`
9494
Internal bool `json:"internal"`
9595
MirrorInterval string `json:"mirror_interval"`
96-
RepoTransfer *RepoTransfer `json:"repo_transfer"`
96+
// swagger:strfmt date-time
97+
MirrorUpdated time.Time `json:"mirror_updated,omitempty"`
98+
RepoTransfer *RepoTransfer `json:"repo_transfer"`
9799
}
98100

99101
// CreateRepoOption options when creating repository

templates/swagger/v1_json.tmpl

+5
Original file line numberDiff line numberDiff line change
@@ -17195,6 +17195,11 @@
1719517195
"type": "string",
1719617196
"x-go-name": "MirrorInterval"
1719717197
},
17198+
"mirror_updated": {
17199+
"type": "string",
17200+
"format": "date-time",
17201+
"x-go-name": "MirrorUpdated"
17202+
},
1719817203
"name": {
1719917204
"type": "string",
1720017205
"x-go-name": "Name"

0 commit comments

Comments
 (0)