We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 53bcdf7 commit b6a9011Copy full SHA for b6a9011
2 files changed
gitdiff/file_header.go
@@ -527,7 +527,7 @@ func hasEpochTimestamp(s string) bool {
527
528
// a valid timestamp can have optional ':' in zone specifier
529
// remove that if it exists so we have a single format
530
- if ts[len(ts)-3] == ':' {
+ if len(ts) >= 3 && ts[len(ts)-3] == ':' {
531
ts = ts[:len(ts)-3] + ts[len(ts)-2:]
532
}
533
gitdiff/file_header_test.go
@@ -724,6 +724,14 @@ func TestHasEpochTimestamp(t *testing.T) {
724
Input: "+++ file.txt\t2019-03-21 12:34:56.789 -0700\n",
725
Output: false,
726
},
727
+ "notTimestamp": {
728
+ Input: "+++ file.txt\trandom text\n",
729
+ Output: false,
730
+ },
731
+ "notTimestampShort": {
732
+ Input: "+++ file.txt\t0\n",
733
734
735
736
737
for name, test := range tests {
0 commit comments