<commit_before>package github

import (
	// Stdlib
	"bufio"
	"encoding/json"
	"fmt"
	"net/http"
	"regexp"
	"strings"

	// Internal
	"github.com/salsaflow/salsaflow-daemon/internal/log"
	"github.com/salsaflow/salsaflow-daemon/internal/utils/githubutils"
	"github.com/salsaflow/salsaflow-daemon/internal/utils/httputils"

	// Vendor
	"github.com/google/go-github/github"
	"github.com/salsaflow/salsaflow/github/issues"
)

type commitCommentEvent struct {
	Comment    *github.RepositoryComment `json:"comment"`
	Repository *github.Repository        `json:"repository"`
}

func handleCommitComment(rw http.ResponseWriter, r *http.Request) {
	// Parse the payload.
	var event commitCommentEvent
	if err := json.NewDecoder(r.Body).Decode(&event); err != nil {
		log.Warn(r, "failed to parse event: %v", err)
		httputils.Status(rw, http.StatusBadRequest)
		return
	}

	// A command is always placed at the beginning of the line
	// and it is prefixed with '!'.
	cmdRegexp := regexp.MustCompile("^[!]([a-zA-Z]+) (.*)$")

	// Process the comment body.
	scanner := bufio.NewScanner(strings.NewReader(*event.Comment.Body))
	for scanner.Scan() {
		// Check whether this is a command and continue if not.
		match := cmdRegexp.FindStringSubmatch(scanner.Text())
		if len(match) == 0 {
			continue
		}
		cmd, arg := match[1], strings.TrimSpace(match[2])

		var err error
		switch cmd {
		case "blocker":
			err = createReviewBlockerFromCommitComment(
				r,
				*event.Repository.Owner.Login,
				*event.Repository.Name,
				event.Comment,
				arg)
		}
		if err != nil {
			httputils.Error(rw, r, err)
			return<commit_msg>handlers/github: Change !blocker to !mustfix<commit_after>package github

import (
	// Stdlib
	"bufio"
	"encoding/json"
	"fmt"
	"net/http"
	"regexp"
	"strings"

	// Internal
	"github.com/salsaflow/salsaflow-daemon/internal/log"
	"github.com/salsaflow/salsaflow-daemon/internal/utils/githubutils"
	"github.com/salsaflow/salsaflow-daemon/internal/utils/httputils"

	// Vendor
	"github.com/google/go-github/github"
	"github.com/salsaflow/salsaflow/github/issues"
)

type commitCommentEvent struct {
	Comment    *github.RepositoryComment `json:"comment"`
	Repository *github.Repository        `json:"repository"`
}

func handleCommitComment(rw http.ResponseWriter, r *http.Request) {
	// Parse the payload.
	var event commitCommentEvent
	if err := json.NewDecoder(r.Body).Decode(&event); err != nil {
		log.Warn(r, "failed to parse event: %v", err)
		httputils.Status(rw, http.StatusBadRequest)
		return
	}

	// A command is always placed at the beginning of the line
	// and it is prefixed with '!'.
	cmdRegexp := regexp.MustCompile("^[!]([a-zA-Z]+) (.*)$")

	// Process the comment body.
	scanner := bufio.NewScanner(strings.NewReader(*event.Comment.Body))
	for scanner.Scan() {
		// Check whether this is a command and continue if not.
		match := cmdRegexp.FindStringSubmatch(scanner.Text())
		if len(match) == 0 {
			continue
		}
		cmd, arg := match[1], strings.TrimSpace(match[2])

		var err error
		switch cmd {
		case "mustfix":
			err = createReviewBlockerFromCommitComment(
				r,
				*event.Repository.Owner.Login,
				*event.Repository.Name,
				event.Comment,
				arg)
		}
		if err != nil {
			httputils.Error(rw, r, err)
			return
{'fraction_non_alphanumeric': 0.13982137357560825, 'fraction_numerical': 0.0018478595626732369, 'mean_word_length': 3.8333333333333335, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3826934', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1148, 'n_words': 241}