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 {
82
82
}
83
83
84
84
// 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.
86
86
// 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
88
88
// left angle bracket, '<', and the email address must not contain a right
89
89
// angle bracket, '>'.
90
90
func ParsePatchIdentity (s string ) (PatchIdentity , error ) {
@@ -109,9 +109,6 @@ func ParsePatchIdentity(s string) (PatchIdentity, error) {
109
109
if emailStart > 0 && emailEnd > 0 {
110
110
email = strings .TrimSpace (s [emailStart :emailEnd ])
111
111
}
112
- if name == "" || email == "" {
113
- return PatchIdentity {}, fmt .Errorf ("invalid identity string: %s" , s )
114
- }
115
112
116
113
return PatchIdentity {Name : name , Email : email }, nil
117
114
}
Original file line number Diff line number Diff line change @@ -34,11 +34,38 @@ func TestParsePatchIdentity(t *testing.T) {
34
34
},
35
35
"missingName" : {
36
36
Input : "<mhaypenny@example.com>" ,
37
- Err : "invalid identity" ,
37
+ Output : PatchIdentity {
38
+ Name : "" ,
39
+ Email : "mhaypenny@example.com" ,
40
+ },
38
41
},
39
42
"missingEmail" : {
40
43
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
+ },
42
69
},
43
70
"unclosedEmail" : {
44
71
Input : "Morton Haypenny <mhaypenny@example.com" ,
You can’t perform that action at this time.
0 commit comments