aboutsummaryrefslogtreecommitdiffstats
path: root/modules/gitgraph/graph_models.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-04 23:46:40 -0800
committerGitHub <noreply@github.com>2024-11-05 07:46:40 +0000
commit24b83ff63e7ffd3d412bc9b509102aa2c507ced1 (patch)
tree3f18ed68bb62f3a597d2417481c7525bf1ac8a41 /modules/gitgraph/graph_models.go
parent1887c75c35c1d16372b1dbe2b792e374b558ce1f (diff)
downloadgitea-24b83ff63e7ffd3d412bc9b509102aa2c507ced1.tar.gz
gitea-24b83ff63e7ffd3d412bc9b509102aa2c507ced1.zip
Fix milestone deadline and date related problems (#32339)
Use zero instead of 9999-12-31 for deadline Fix #32291 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'modules/gitgraph/graph_models.go')
-rw-r--r--modules/gitgraph/graph_models.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go
index e48fef8b9d..191b0b3afc 100644
--- a/modules/gitgraph/graph_models.go
+++ b/modules/gitgraph/graph_models.go
@@ -8,6 +8,7 @@ import (
"context"
"fmt"
"strings"
+ "time"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
@@ -192,6 +193,14 @@ var RelationCommit = &Commit{
Row: -1,
}
+func parseGitTime(timeStr string) time.Time {
+ t, err := time.Parse(time.RFC3339, timeStr)
+ if err != nil {
+ return time.Unix(0, 0)
+ }
+ return t
+}
+
// NewCommit creates a new commit from a provided line
func NewCommit(row, column int, line []byte) (*Commit, error) {
data := bytes.SplitN(line, []byte("|"), 5)
@@ -206,7 +215,7 @@ func NewCommit(row, column int, line []byte) (*Commit, error) {
// 1 matches git log --pretty=format:%H => commit hash
Rev: string(data[1]),
// 2 matches git log --pretty=format:%ad => author date (format respects --date= option)
- Date: string(data[2]),
+ Date: parseGitTime(string(data[2])),
// 3 matches git log --pretty=format:%h => abbreviated commit hash
ShortRev: string(data[3]),
// 4 matches git log --pretty=format:%s => subject
@@ -245,7 +254,7 @@ type Commit struct {
Column int
Refs []git.Reference
Rev string
- Date string
+ Date time.Time
ShortRev string
Subject string
}