Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/git')
-rw-r--r--internal/git/localrepo/commit_test.go14
-rw-r--r--internal/git/signature.go6
-rw-r--r--internal/git/signature_test.go2
3 files changed, 15 insertions, 7 deletions
diff --git a/internal/git/localrepo/commit_test.go b/internal/git/localrepo/commit_test.go
index c92cb6f9f..25202f351 100644
--- a/internal/git/localrepo/commit_test.go
+++ b/internal/git/localrepo/commit_test.go
@@ -20,6 +20,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func TestRepo_ReadCommit(t *testing.T) {
@@ -382,14 +383,16 @@ func testWriteCommit(t *testing.T, ctx context.Context) {
tb.Skip()
}
+ commitDate := time.Date(2023, time.November, 10, 23, 0, 0, 0, time.UTC)
+
cfg := WriteCommitConfig{
TreeID: treeA.OID,
AuthorName: gittest.DefaultCommitterName,
AuthorEmail: gittest.DefaultCommitterMail,
CommitterName: gittest.DefaultCommitterName,
CommitterEmail: gittest.DefaultCommitterMail,
- AuthorDate: gittest.DefaultCommitTime,
- CommitterDate: gittest.DefaultCommitTime,
+ AuthorDate: commitDate,
+ CommitterDate: commitDate,
Message: "my custom message",
GitConfig: config.Git{
SigningKey: "testdata/signing_gpg_key",
@@ -402,7 +405,12 @@ func testWriteCommit(t *testing.T, ctx context.Context) {
commit, err := repo.ReadCommit(ctx, git.Revision(oid))
require.NoError(t, err)
- require.Equal(t, gittest.DefaultCommitAuthor, commit.Author)
+ require.Equal(t, &gitalypb.CommitAuthor{
+ Name: []byte(gittest.DefaultCommitterName),
+ Email: []byte(gittest.DefaultCommitterMail),
+ Date: timestamppb.New(commitDate),
+ Timezone: []byte("+0000"),
+ }, commit.Author)
require.Equal(t, "my custom message", string(commit.Body))
data, err := repo.ReadObject(ctx, oid)
diff --git a/internal/git/signature.go b/internal/git/signature.go
index 6c1754272..300ad7a83 100644
--- a/internal/git/signature.go
+++ b/internal/git/signature.go
@@ -10,8 +10,8 @@ import (
)
const (
- // rfc2822DateFormat is the date format that Git typically uses for dates.
- rfc2822DateFormat = "Mon Jan 02 2006 15:04:05 -0700"
+ // Rfc2822DateFormat is the date format that Git typically uses for dates.
+ Rfc2822DateFormat = "Mon Jan 02 2006 15:04:05 -0700"
)
var signatureSanitizer = strings.NewReplacer("\n", "", "<", "", ">", "")
@@ -47,7 +47,7 @@ func NewSignature(name, email string, when time.Time) Signature {
// If you need to format a time to be used in signatures directly, e.g. because it is passed to git-hash-object(1), you
// can use `FormatSignatureTime()` instead.
func FormatTime(t time.Time) string {
- return t.Format(rfc2822DateFormat)
+ return t.Format(Rfc2822DateFormat)
}
// FormatSignatureTime formats a time such that it can be embedded into a tag or commit object directly.
diff --git a/internal/git/signature_test.go b/internal/git/signature_test.go
index 6a98d64d7..8fc1f9294 100644
--- a/internal/git/signature_test.go
+++ b/internal/git/signature_test.go
@@ -114,7 +114,7 @@ func TestFormatTime(t *testing.T) {
// We use `time.ParseInLocation()` here such that Go won't automatically translate e.g. `+0200`
// into "CEST" or `time.Local`.
- actualParsedTime, err := time.ParseInLocation(rfc2822DateFormat, actualString, time.FixedZone("", 0))
+ actualParsedTime, err := time.ParseInLocation(Rfc2822DateFormat, actualString, time.FixedZone("", 0))
require.NoError(t, err)
require.Equal(t, tc.expectedParsedTime, actualParsedTime)