12345678910111213141516171819202122232425262728293031323334353637383940 |
- package git
- import (
- "bytes"
- "strconv"
- "time"
- )
- type Signature struct {
- Email string
- Name string
- When time.Time
- }
- func newSignatureFromCommitline(line []byte) (*Signature, error) {
- sig := new(Signature)
- emailstart := bytes.IndexByte(line, '<')
- sig.Name = string(line[:emailstart-1])
- emailstop := bytes.IndexByte(line, '>')
- sig.Email = string(line[emailstart+1 : emailstop])
- timestop := bytes.IndexByte(line[emailstop+2:], ' ')
- timestring := string(line[emailstop+2 : emailstop+2+timestop])
- seconds, err := strconv.ParseInt(timestring, 10, 64)
- if err != nil {
- return nil, err
- }
- sig.When = time.Unix(seconds, 0)
- return sig, nil
- }
|