From 07e4e61cf3d9999f1760a445ce0214eb3f0e2aaa Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Tue, 17 Jan 2023 10:26:16 +0000 Subject: [PATCH 1/2] Fix pull request API field `closed_at` always being `null` --- services/convert/pull.go | 1 + 1 file changed, 1 insertion(+) diff --git a/services/convert/pull.go b/services/convert/pull.go index db0add6cdee7b..154f066fce0b4 100644 --- a/services/convert/pull.go +++ b/services/convert/pull.go @@ -72,6 +72,7 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u Deadline: apiIssue.Deadline, Created: pr.Issue.CreatedUnix.AsTimePtr(), Updated: pr.Issue.UpdatedUnix.AsTimePtr(), + Closed: pr.Issue.ClosedUnix.AsTimePtr(), AllowMaintainerEdit: pr.AllowMaintainerEdit, From 241f4af737fda4942744f1f300b2aa47e51307f5 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Tue, 17 Jan 2023 10:48:25 +0000 Subject: [PATCH 2/2] Should be null if it hasn't been closed --- services/convert/pull.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/convert/pull.go b/services/convert/pull.go index 154f066fce0b4..cdf72e78057f5 100644 --- a/services/convert/pull.go +++ b/services/convert/pull.go @@ -72,7 +72,6 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u Deadline: apiIssue.Deadline, Created: pr.Issue.CreatedUnix.AsTimePtr(), Updated: pr.Issue.UpdatedUnix.AsTimePtr(), - Closed: pr.Issue.ClosedUnix.AsTimePtr(), AllowMaintainerEdit: pr.AllowMaintainerEdit, @@ -89,6 +88,10 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u }, } + if pr.Issue.ClosedUnix != 0 { + apiPullRequest.Closed = pr.Issue.ClosedUnix.AsTimePtr() + } + gitRepo, err := git.OpenRepository(ctx, pr.BaseRepo.RepoPath()) if err != nil { log.Error("OpenRepository[%s]: %v", pr.BaseRepo.RepoPath(), err)