summaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io/git/signature.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/code.gitea.io/git/signature.go')
-rw-r--r--vendor/code.gitea.io/git/signature.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/vendor/code.gitea.io/git/signature.go b/vendor/code.gitea.io/git/signature.go
index 95eb1bbe07..7dc9763b5d 100644
--- a/vendor/code.gitea.io/git/signature.go
+++ b/vendor/code.gitea.io/git/signature.go
@@ -32,17 +32,22 @@ func newSignatureFromCommitline(line []byte) (_ *Signature, err error) {
sig.Email = string(line[emailStart+1 : emailEnd])
// Check date format.
- firstChar := line[emailEnd+2]
- if firstChar >= 48 && firstChar <= 57 {
- timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
- timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
- seconds, _ := strconv.ParseInt(timestring, 10, 64)
- sig.When = time.Unix(seconds, 0)
- } else {
- sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailEnd+2:]))
- if err != nil {
- return nil, err
+ if len(line) > emailEnd+2 {
+ firstChar := line[emailEnd+2]
+ if firstChar >= 48 && firstChar <= 57 {
+ timestop := bytes.IndexByte(line[emailEnd+2:], ' ')
+ timestring := string(line[emailEnd+2 : emailEnd+2+timestop])
+ seconds, _ := strconv.ParseInt(timestring, 10, 64)
+ sig.When = time.Unix(seconds, 0)
+ } else {
+ sig.When, err = time.Parse("Mon Jan _2 15:04:05 2006 -0700", string(line[emailEnd+2:]))
+ if err != nil {
+ return nil, err
+ }
}
+ } else {
+ // Fall back to unix 0 time
+ sig.When = time.Unix(0, 0)
}
return sig, nil
}