-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor parseSignatureFromCommitLine (#29054) (#29108)
Backport #29054. Fix #28840 This backport is for 1.21 only and it is different from the change in 1.22: this backport still accept the legacy date format to avoid breaking.
- Loading branch information
1 parent
1aaeec6
commit 732d511
Showing
8 changed files
with
104 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package git | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseSignatureFromCommitLine(t *testing.T) { | ||
tests := []struct { | ||
line string | ||
want *Signature | ||
}{ | ||
{ | ||
line: "a b <c@d.com> 12345 +0100", | ||
want: &Signature{ | ||
Name: "a b", | ||
Email: "c@d.com", | ||
When: time.Unix(12345, 0).In(time.FixedZone("", 3600)), | ||
}, | ||
}, | ||
{ | ||
line: "bad line", | ||
want: &Signature{Name: "bad line"}, | ||
}, | ||
{ | ||
line: "bad < line", | ||
want: &Signature{Name: "bad < line"}, | ||
}, | ||
{ | ||
line: "bad > line", | ||
want: &Signature{Name: "bad > line"}, | ||
}, | ||
{ | ||
line: "bad-line <name@example.com>", | ||
want: &Signature{Name: "bad-line <name@example.com>"}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
got := parseSignatureFromCommitLine(test.line) | ||
assert.EqualValues(t, test.want, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters