mirror of
https://github.com/bluekeyes/go-gitdiff
synced 2026-06-08 13:18:30 +00:00
@@ -527,7 +527,7 @@ func hasEpochTimestamp(s string) bool {
|
||||
|
||||
// a valid timestamp can have optional ':' in zone specifier
|
||||
// remove that if it exists so we have a single format
|
||||
if ts[len(ts)-3] == ':' {
|
||||
if len(ts) >= 3 && ts[len(ts)-3] == ':' {
|
||||
ts = ts[:len(ts)-3] + ts[len(ts)-2:]
|
||||
}
|
||||
|
||||
|
||||
@@ -724,6 +724,14 @@ func TestHasEpochTimestamp(t *testing.T) {
|
||||
Input: "+++ file.txt\t2019-03-21 12:34:56.789 -0700\n",
|
||||
Output: false,
|
||||
},
|
||||
"notTimestamp": {
|
||||
Input: "+++ file.txt\trandom text\n",
|
||||
Output: false,
|
||||
},
|
||||
"notTimestampShort": {
|
||||
Input: "+++ file.txt\t0\n",
|
||||
Output: false,
|
||||
},
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
|
||||
Reference in New Issue
Block a user