<commit_before>package git

import (
	"fmt"
	"os"

	"github.com/libgit2/git2go"
)

type GitStatus struct{}

func getRepository() (*git.Repository, error) {
	workingDirectory, err := os.Getwd()
	if nil != err {
		return nil, err
	}

	repo, err := git.OpenRepository(workingDirectory)
	if err != nil {
		return nil, err
	}

	return repo, nil
}

func (gitStatus GitStatus) Prompt(parameter string) (string, error) {
	repo, err := getRepository()
	if nil != err {
		return "", nil
	}
	color := "{GREEN:bold}"

	head := GitHead{}.Init(repo)
	prompt, err := head.Name()
	if nil != err {
		return "", err
	}

	changes := GitChanges{}.Init(repo)
	if changes.HasChanges() {
		if changes.ConflictedFilesCount() > 0 {
			prompt += " !" + fmt.Sprint(changes.ConflictedFilesCount())
			color = "{RED:bold}"
		} else {
			prompt += " " + fmt.Sprint(changes.StagedFilesCount(), changes.ModifiedFilesCount(), changes.UntrackedFilesCount())

			if changes.ModifiedFilesCount() > 0 {
				color = "{RED:bold}"
			} else if changes.StagedFilesCount() > 0 {
				color = "{YELLOW:bold}"
			} else if changes.UntrackedFilesCount() > 0 {
				color = "{CYAN:bold}"
			}
		}
	}

	repo.Free()
<commit_msg>Fix new repo status on git plugin<commit_after>package git

import (
	"fmt"
	"os"
	"strings"

	"github.com/libgit2/git2go"
)

type GitStatus struct{}

func getRepository() (*git.Repository, error) {
	workingDirectory, err := os.Getwd()
	if nil != err {
		return nil, err
	}

	repo, err := git.OpenRepository(workingDirectory)
	if err != nil {
		return nil, err
	}

	return repo, nil
}

func (gitStatus GitStatus) Prompt(parameter string) (string, error) {
	repo, err := getRepository()
	if nil != err {
		return "", nil
	}
	color := "{GREEN:bold}"

	head := GitHead{}.Init(repo)
	prompt, _ := head.Name()

	changes := GitChanges{}.Init(repo)
	if changes.HasChanges() {
		if changes.ConflictedFilesCount() > 0 {
			prompt += " !" + fmt.Sprint(changes.ConflictedFilesCount())
			color = "{RED:bold}"
		} else {
			prompt += " " + fmt.Sprint(changes.StagedFilesCount(), changes.ModifiedFilesCount(), changes.UntrackedFilesCount())

			if changes.ModifiedFilesCount() > 0 {
				color = "{RED:bold}"
			} else if changes.StagedFilesCount() > 0 {
				color = "{YELLOW:bold}"
			} else if changes.UntrackedFilesCount() > 0 {
				color = "{CYAN:bold}"
			}
		}
	}

	repo.Free()

	prompt = strings.TrimSpace(prompt)
{'fraction_non_alphanumeric': 0.15981543624161074, 'fraction_numerical': 0.0050335570469798654, 'mean_word_length': 3.7604790419161676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7518895', 'n_tokens_mistral': 922, 'n_tokens_neox': 822, 'n_words': 193}