<commit_before>package gitmedia

import (
	"../gitconfig"
	"fmt"
)

type InitCommand struct {
	*Command
}

var (
	cleanFilterKey  = "filter.media.clean"
	cleanFilterVal  = "git-media-clean %f"
	smudgeFilterKey = "filter.media.smudge"
	smudgeFilterVal = "git-media-smudge %f"
)

func (c *InitCommand) Run() {
	clean := gitconfig.Find(cleanFilterKey)
	if clean == "" {
		fmt.Println("Installing clean filter")
		gitconfig.SetGlobal(cleanFilterKey, cleanFilterVal)
	} else if clean != cleanFilterVal {
		fmt.Printf("Clean filter should be \"%s\" but is \"%s\"\n", cleanFilterVal, clean)
	}

	smudge := gitconfig.Find(smudgeFilterKey)
	if smudge == "" {
		fmt.Println("Installing smudge filter")
		gitconfig.SetGlobal(smudgeFilterKey, smudgeFilterVal)
	} else if smudge != smudgeFilterVal {
		fmt.Printf("Smudge filter should be \"%s\" but is \"%s\"\n", smudgeFilterVal, smudge)
	}

	fmt.Println("git media initialized")
}

func init() {
	registerCommand("init", func(c *Command) RunnableCommand {
		return &InitCommand{Command: c}
	})
}<commit_msg>git media init resets config<commit_after>package gitmedia

import (
	"../gitconfig"
	"fmt"
	"regexp"
)

type InitCommand struct {
	*Command
}

var (
	cleanFilterKey  = "filter.media.clean"
	cleanFilterVal  = "git-media-clean %f"
	smudgeFilterKey = "filter.media.smudge"
	smudgeFilterVal = "git-media-smudge %f"
	valueRegexp     = regexp.MustCompile("\\Agit[\\-\\s]media")
)

func (c *InitCommand) Run() {
	clean := gitconfig.Find(cleanFilterKey)
	if shouldReset(clean) {
		fmt.Println("Installing clean filter")
		gitconfig.SetGlobal(cleanFilterKey, cleanFilterVal)
	} else if clean != cleanFilterVal {
		fmt.Printf("Clean filter should be \"%s\" but is \"%s\"\n", cleanFilterVal, clean)
	}

	smudge := gitconfig.Find(smudgeFilterKey)
	if shouldReset(smudge) {
		fmt.Println("Installing smudge filter")
		gitconfig.SetGlobal(smudgeFilterKey, smudgeFilterVal)
	} else if smudge != smudgeFilterVal {
		fmt.Printf("Smudge filter should be \"%s\" but is \"%s\"\n", smudgeFilterVal, smudge)
	}

	fmt.Println("git media initialized")
}

func shouldReset(value string) bool {
	if len(value) == 0 {
		return true
	}
	return valueRegexp.MatchString(value)
}

func init() {
	registerCommand("init", func(c *Command) RunnableCommand {
		return &InitCommand{Command: c}
	})
}
{'fraction_non_alphanumeric': 0.14378518839324383, 'fraction_numerical': 0.00043308791684711995, 'mean_word_length': 4.634146341463414, 'pattern_counts': {'":': 0, '<': 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': '887954', 'n_tokens_mistral': 839, 'n_tokens_neox': 818, 'n_words': 182}