RGK2IUMOM7CWPSAHLJBLIRJ7Y6HZPHLTLJ7ADTWVBMI5ZJNBGY2AC
5ETDKF5FO7AE7G6ZGP5WAMMY6VQZT2KQ75UZ3OD2WM24Q2JZPAOQC
EGKSUIOBLW2DUXFNMXXVQ2NDLE7YQE27YHNE2R6YSC2K2ELG6WJAC
Y7VFVY6EMR7FMVCTPLBIYVRI2DJTOSUK7LSRRRIODT3G57FR7Z4QC
RTQQLOCOBMMY5RQ6QI7TYKILLSSW5YNVPA33NL4MHM27QXMOCKPQC
KZ4XMKSPLDYKDWCDZXTIJXZPXUZPMGYSZAIIJTQQSYDZVWOZVI5AC
RFMRCLJXZIUTMQOGKVN2YYYJC2HHDJP6NS6K7P6PGIZ3S6QF77SAC
// unquote tries to unquote various types of quoted strings, and returns the
// result. If none of the formats works, it returns s unchanged except for
// trimming off whitespace.
func unquote(s string) string {
s = strings.TrimSpace(s)
switch {
case strings.HasPrefix(s, "'''") && strings.HasSuffix(s, "'''"):
return strings.TrimPrefix(strings.TrimSuffix(s, "'''"), "'''")
case strings.HasPrefix(s, "'") && strings.HasSuffix(s, "'"):
return strings.TrimPrefix(strings.TrimSuffix(s, "'"), "'")
case strings.HasPrefix(s, "\"") && strings.HasSuffix(s, "\""):
unquoted, err := strconv.Unquote(s)
if err == nil {
return unquoted
}
}
return s
}
var authorsHeader = []byte("\n[[authors]]\n")
// Since the email address is missing from the log,
// we'll try to find it in the output of pijul change.
changeInfo, err := exec.Command("pijul", "change", c.Hash).Output()
if err != nil {
printErrorAndExit("Error from pijul change:", err)
}
if i := bytes.Index(changeInfo, authorsHeader); i != -1 {
var name, email string
s := bufio.NewScanner(bytes.NewReader(changeInfo[i+len(authorsHeader):]))
for s.Scan() {
line := s.Text()
if line == "" {
break
}
if strings.HasPrefix(line, "email =") {
email = unquote(strings.TrimPrefix(line, "email ="))
} else if strings.HasPrefix(line, "name =") {
name = unquote(strings.TrimPrefix(line, "name ="))
}
}
if name != "" && email != "" {
author = name + " <" + email + ">"
}
}