"net/mail"
"os"
"os/exec"
+ "regexp"
"strconv"
"strings"
"syscall"
"go.stargrave.org/sgblog"
)
+var hashFinder = regexp.MustCompile("([0-9a-f]{40})")
+
// Remove various whitespaces and excess lines, because git-notes-add
// will remove and we have to know exact bytes count
func cleanupBody(body string) string {
log.Fatal(err)
}
- subj = strings.TrimPrefix(subj, "Re: ")
+ subj = hashFinder.FindString(subj)
+ if subj == "" {
+ log.Fatal("no commit hash found in subject")
+ }
if h, err := hex.DecodeString(subj); err != nil || len(h) != sha1.Size {
os.Exit(0)
}