]> Sergey Matveev's repositories - sgblog.git/blobdiff - cmd/sgblog/main.go
Comments Atom feeds
[sgblog.git] / cmd / sgblog / main.go
index 9b03e4cae1ab04b89a8b87a59c2f614165f6d0a1..05654c0760942625cf2c8fcd04be124c60379bba 100644 (file)
@@ -20,6 +20,8 @@ package main
 
 import (
        "bytes"
+       "crypto/sha1"
+       "fmt"
        "io/ioutil"
        "os"
        "regexp"
@@ -36,9 +38,10 @@ const (
 )
 
 var (
-       sha1DigestRe = regexp.MustCompilePOSIX("([0-9a-f]{40,40})")
+       sha1DigestRe = regexp.MustCompilePOSIX(fmt.Sprintf("([0-9a-f]{%d,%d})", sha1.Size*2, sha1.Size*2))
        repo         *git.Repository
        notesTree    *object.Tree
+       commentsRef  *plumbing.Reference
        commentsTree *object.Tree
 )
 
@@ -134,7 +137,6 @@ func initRepo(cfg *Cfg) (*plumbing.Hash, error) {
        headHash := head.Hash()
        if notes, err := repo.Notes(); err == nil {
                var notesRef *plumbing.Reference
-               var commentsRef *plumbing.Reference
                notes.ForEach(func(ref *plumbing.Reference) error {
                        switch string(ref.Name()) {
                        case "refs/notes/commits":