Skip to content

Commit 6720760

Browse files
committed
fix: replace time comparison object
1 parent e1165ce commit 6720760

File tree

4 files changed

+78
-69
lines changed

4 files changed

+78
-69
lines changed

api/jiaozifs.gen.go

Lines changed: 66 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ components:
4747
description: return items after this value
4848
schema:
4949
type: string
50-
format: date-time
50+
format: date-time-ns
5151

5252
PaginationAmount:
5353
in: query

controller/repository_ctl.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,15 @@ func (repositoryCtl RepositoryController) GetCommitsInRepository(ctx context.Con
402402
for {
403403
commit, err := iter.Next()
404404
if err == nil {
405-
if params.After != nil && commit.Commit().CreatedAt.Add(time.Nanosecond).After(*params.After) {
406-
continue
405+
if params.After != nil {
406+
parseTime, err := time.Parse(time.RFC3339Nano, *params.After)
407+
if err != nil {
408+
w.Error(err)
409+
return
410+
}
411+
if commit.Commit().Committer.When.Add(time.Nanosecond).After(parseTime) {
412+
continue
413+
}
407414
}
408415
if params.Amount != nil && len(commits) == *params.Amount {
409416
break

integrationtest/repo_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7+
"time"
78

89
"github.com/jiaozifs/jiaozifs/api"
910
apiimpl "github.com/jiaozifs/jiaozifs/api/api_impl"
@@ -412,7 +413,7 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
412413
convey.So((*result.JSON200)[0].Message, convey.ShouldEqual, "third commit")
413414

414415
newResp, err := client.GetCommitsInRepository(ctx, userName, repoName, &api.GetCommitsInRepositoryParams{
415-
After: utils.Time((*result.JSON200)[0].CreatedAt),
416+
After: utils.String((*result.JSON200)[0].Committer.When.Format(time.RFC3339Nano)),
416417
Amount: utils.Int(1),
417418
RefName: utils.String(controller.DefaultBranchName),
418419
})

0 commit comments

Comments
 (0)