<commit_before>package git

import (
	"errors"
	"fmt"
	"github.com/str1ngs/util/file"
	"io/ioutil"
	"path"
	"strings"
)

var (
	join = path.Join
)

const (
	git_head = "%s/.git/HEAD"
)

func Branch(path string) (string, error) {
	head := fmt.Sprintf(git_head, path)
	if !file.Exists(head) {
		return "", errors.New(".git not found in " + path)
	}
	b, err := ioutil.ReadFile(head)
	if err != nil {
		return "", err
	}
	in := strings.Split(string(b), "/")
	branch := in[len(in)-1]
	branch = strings.Trim(branch, "\n\r")
	return branch, nil
}
<commit_msg>error on empty git branch, dont need errors pkg<commit_after>package git

import (
	"fmt"
	"github.com/str1ngs/util/file"
	"io/ioutil"
	"path"
	"strings"
)

var (
	join = path.Join
)

const (
	git_head = "%s/.git/HEAD"
)

func Branch(path string) (string, error) {
	head := fmt.Sprintf(git_head, path)
	if !file.Exists(head) {
		return "", fmt.Errorf(".git not found in %s", path)
	}
	b, err := ioutil.ReadFile(head)
	if err != nil {
		return "", err
	}
	in := strings.Split(string(b), "/")
	branch := in[len(in)-1]
	branch = strings.Trim(branch, "\n\r")
	if branch == "" {
		return "", fmt.Errorf("No branch found")
	}
	return branch, nil
}

{'fraction_non_alphanumeric': 0.18760469011725292, 'fraction_numerical': 0.0033500837520938024, 'mean_word_length': 3.5610687022900764, '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': '601970', 'n_tokens_mistral': 498, 'n_tokens_neox': 489, 'n_words': 112}