Skip to content

Commit 0ee7cbf

Browse files
kilimnikGiteaBot
andauthored
Fix push mirror, wrong timestamp format (#27153)
I noticed, that the push mirrors endpoint, is the only endpoint which returns the times in long format rather than as time.Time(). I think the behavior should be consistent across the project. ---- ## ⚠️ BREAKING ⚠️ This PR changes the time format used in API responses for all push_mirror endpoints which return a push mirror. --------- Co-authored-by: Giteabot <[email protected]>
1 parent 5f7388e commit 0ee7cbf

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

modules/structs/mirror.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package structs
55

6+
import "time"
7+
68
// CreatePushMirrorOption represents need information to create a push mirror of a repository.
79
type CreatePushMirrorOption struct {
810
RemoteAddress string `json:"remote_address"`
@@ -15,12 +17,14 @@ type CreatePushMirrorOption struct {
1517
// PushMirror represents information of a push mirror
1618
// swagger:model
1719
type PushMirror struct {
18-
RepoName string `json:"repo_name"`
19-
RemoteName string `json:"remote_name"`
20-
RemoteAddress string `json:"remote_address"`
21-
CreatedUnix string `json:"created"`
22-
LastUpdateUnix string `json:"last_update"`
23-
LastError string `json:"last_error"`
24-
Interval string `json:"interval"`
25-
SyncOnCommit bool `json:"sync_on_commit"`
20+
RepoName string `json:"repo_name"`
21+
RemoteName string `json:"remote_name"`
22+
RemoteAddress string `json:"remote_address"`
23+
// swagger:strfmt date-time
24+
CreatedUnix time.Time `json:"created"`
25+
// swagger:strfmt date-time
26+
LastUpdateUnix *time.Time `json:"last_update"`
27+
LastError string `json:"last_error"`
28+
Interval string `json:"interval"`
29+
SyncOnCommit bool `json:"sync_on_commit"`
2630
}

services/convert/mirror.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func ToPushMirror(pm *repo_model.PushMirror) (*api.PushMirror, error) {
1515
RepoName: repo.Name,
1616
RemoteName: pm.RemoteName,
1717
RemoteAddress: pm.RemoteAddress,
18-
CreatedUnix: pm.CreatedUnix.FormatLong(),
19-
LastUpdateUnix: pm.LastUpdateUnix.FormatLong(),
18+
CreatedUnix: pm.CreatedUnix.AsTime(),
19+
LastUpdateUnix: pm.LastUpdateUnix.AsTimePtr(),
2020
LastError: pm.LastError,
2121
Interval: pm.Interval.String(),
2222
SyncOnCommit: pm.SyncOnCommit,

templates/swagger/v1_json.tmpl

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)