Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MirrorUpdated field to Repository API type #18267

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/convert/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package convert

import (
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/perm"
Expand Down Expand Up @@ -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})

mirrorInterval := ""
mirrorUpdated, _ := time.Parse(time.RFC3339, "0001-01-01T00:00:00Z")
petergardfjall marked this conversation as resolved.
Show resolved Hide resolved
if repo.IsMirror {
var err error
repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
if err == nil {
mirrorInterval = repo.Mirror.Interval.String()
mirrorUpdated = repo.Mirror.UpdatedUnix.AsTime()
}
}

Expand Down Expand Up @@ -166,6 +170,7 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo
AvatarURL: repo.AvatarLink(),
Internal: !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePrivate,
MirrorInterval: mirrorInterval,
MirrorUpdated: mirrorUpdated,
RepoTransfer: transfer,
}
}
Expand Down
4 changes: 3 additions & 1 deletion modules/structs/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ type Repository struct {
AvatarURL string `json:"avatar_url"`
Internal bool `json:"internal"`
MirrorInterval string `json:"mirror_interval"`
RepoTransfer *RepoTransfer `json:"repo_transfer"`
// swagger:strfmt date-time
MirrorUpdated time.Time `json:"mirror_updated"`
RepoTransfer *RepoTransfer `json:"repo_transfer"`
}

// CreateRepoOption options when creating repository
Expand Down
5 changes: 5 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17195,6 +17195,11 @@
"type": "string",
"x-go-name": "MirrorInterval"
},
"mirror_updated": {
"type": "string",
"format": "date-time",
"x-go-name": "MirrorUpdated"
},
"name": {
"type": "string",
"x-go-name": "Name"
Expand Down