changelog: Modified commit date format
Changed commit date format to Mon, 2 Jan 2006. Also fixed output for certain gitcommit tests.
BUG=b/160901711
TEST=unittests, run local
Change-Id: Iae971a6b917b9ab9ab5e2c6a493b1c085ddf8c0f
diff --git a/src/pkg/changelog/gitcommit.go b/src/pkg/changelog/gitcommit.go
index c9c2a65..39d49f4 100755
--- a/src/pkg/changelog/gitcommit.go
+++ b/src/pkg/changelog/gitcommit.go
@@ -18,13 +18,14 @@
"errors"
"regexp"
"strings"
- "time"
"go.chromium.org/luci/common/proto/git"
)
-const bugLinePrefix string = "BUG="
-const releaseNoteLinePrefix string = "RELEASE_NOTE="
+const (
+ bugLinePrefix string = "BUG="
+ releaseNoteLinePrefix string = "RELEASE_NOTE="
+)
// RepoLog contains a changelist for a particular repository
type RepoLog struct {
@@ -112,7 +113,7 @@
func commitTime(commit *git.Commit) string {
if commit.Committer != nil {
- return commit.Committer.Time.AsTime().Format(time.RFC1123)
+ return commit.Committer.Time.AsTime().Format("Mon, 2 Jan 2006")
}
return "None"
}
diff --git a/src/pkg/changelog/gitcommit_test.go b/src/pkg/changelog/gitcommit_test.go
index 268245d..7c623ac 100644
--- a/src/pkg/changelog/gitcommit_test.go
+++ b/src/pkg/changelog/gitcommit_test.go
@@ -29,7 +29,7 @@
parent string = "7645df3136c5b5e43eb1af182b0c67d78ca2d517"
authorName string = "Austin Yuan"
committerName string = "Boston Yuan"
- timeVal string = "Sat, 01 Feb 2020 08:15:00 UTC"
+ timeVal string = "Sat, 1 Feb 2020"
)
var authorTime time.Time
@@ -339,9 +339,9 @@
case !reflect.DeepEqual(commit.Bugs, test.Bugs[i]):
t.Errorf("exptected bugs %#v, got %#v", test.Bugs[i], commit.Bugs)
case commit.ReleaseNote != test.ReleaseNote[i]:
- t.Errorf("expected release note %s, got %s", test.ReleaseNote, commit.ReleaseNote)
+ t.Errorf("expected release note %s, got %s", test.ReleaseNote[i], commit.ReleaseNote)
case commit.CommitTime != test.CommitTime[i]:
- t.Errorf("expected commit time %s, got %s", test.CommitTime, commit.CommitTime)
+ t.Errorf("expected commit time %s, got %s", test.CommitTime[i], commit.CommitTime)
}
}
})