File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,9 @@ func (i PatchIdentity) String() string {
8282}
8383
8484// ParsePatchIdentity parses a patch identity string. A valid string contains a
85- // non-empty name followed by an email address in angle brackets. Like Git,
85+ // name followed by an email address in angle brackets.
8686// ParsePatchIdentity does not require that the email address is valid or
87- // properly formatted, only that it is non-empty . The name must not contain a
87+ // properly formatted. The name must not contain a
8888// left angle bracket, '<', and the email address must not contain a right
8989// angle bracket, '>'.
9090func ParsePatchIdentity (s string ) (PatchIdentity , error ) {
@@ -109,9 +109,6 @@ func ParsePatchIdentity(s string) (PatchIdentity, error) {
109109 if emailStart > 0 && emailEnd > 0 {
110110 email = strings .TrimSpace (s [emailStart :emailEnd ])
111111 }
112- if name == "" || email == "" {
113- return PatchIdentity {}, fmt .Errorf ("invalid identity string: %s" , s )
114- }
115112
116113 return PatchIdentity {Name : name , Email : email }, nil
117114}
Original file line number Diff line number Diff line change @@ -34,11 +34,38 @@ func TestParsePatchIdentity(t *testing.T) {
3434 },
3535 "missingName" : {
3636 Input : "<mhaypenny@example.com>" ,
37- Err : "invalid identity" ,
37+ Output : PatchIdentity {
38+ Name : "" ,
39+ Email : "mhaypenny@example.com" ,
40+ },
3841 },
3942 "missingEmail" : {
4043 Input : "Morton Haypenny" ,
41- Err : "invalid identity" ,
44+ Output : PatchIdentity {
45+ Name : "" ,
46+ Email : "" ,
47+ },
48+ },
49+ "emptyEmail" : {
50+ Input : "Morton Haypenny <>" ,
51+ Output : PatchIdentity {
52+ Name : "Morton Haypenny" ,
53+ Email : "" ,
54+ },
55+ },
56+ "missingNameAndEmail" : {
57+ Input : "" ,
58+ Output : PatchIdentity {
59+ Name : "" ,
60+ Email : "" ,
61+ },
62+ },
63+ "emptyNameAndEmail" : {
64+ Input : " <>" ,
65+ Output : PatchIdentity {
66+ Name : "" ,
67+ Email : "" ,
68+ },
4269 },
4370 "unclosedEmail" : {
4471 Input : "Morton Haypenny <mhaypenny@example.com" ,
You can’t perform that action at this time.
0 commit comments