Skip to content

Commit

Permalink
fix: embed template for comment gen
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Nov 29, 2024
1 parent 6fe44bb commit 6af501d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions contribs/github-bot/internal/check/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package check

import (
"bytes"
_ "embed"
"errors"
"fmt"
"regexp"
Expand All @@ -11,11 +12,13 @@ import (
"github.com/gnolang/gno/contribs/github-bot/internal/client"
"github.com/gnolang/gno/contribs/github-bot/internal/config"
"github.com/gnolang/gno/contribs/github-bot/internal/utils"

"github.com/google/go-github/v64/github"
"github.com/sethvargo/go-githubactions"
)

//go:embed comment.tmpl
var tmplString string // Embed template used for comment generation.

var errTriggeredByBot = errors.New("event triggered by bot")

// Compile regex only once.
Expand Down Expand Up @@ -218,8 +221,7 @@ func generateComment(content CommentContent) (string, error) {
}

// Bind markdown stripping function to template generator.
const tmplFile = "comment.tmpl"
tmpl, err := template.New(tmplFile).Funcs(funcMap).ParseFiles(tmplFile)
tmpl, err := template.New("comment").Funcs(funcMap).Parse(tmplString)
if err != nil {
return "", fmt.Errorf("unable to init template: %w", err)
}
Expand Down

0 comments on commit 6af501d

Please sign in to comment.