<commit_before>package git

import (
	"errors"
	"io"
	"os"
	"path/filepath"
	"strings"
)

var (
	ErrBranchExisted = errors.New("branch has existed")
)

func IsBranchExist(repoPath, branchName string) bool {
	branchPath := filepath.Join(repoPath, "refs/heads", branchName)
	return isFile(branchPath)
}

func (repo *Repository) IsBranchExist(branchName string) bool {
	branchPath := filepath.Join(repo.Path, "refs/heads", branchName)
	return isFile(branchPath)
}

func (repo *Repository) GetBranches() ([]string, error) {
	return repo.readRefDir("refs/heads", "")
}

func (repo *Repository) CreateBranch(branchName, idStr string) error {
	return repo.createRef("heads", branchName, idStr)
}

func (repo *Repository) createRef(head, branchName, idStr string) error {
	id, err := NewIdFromString(idStr)
	if err != nil {
		return err
	}

	branchPath := filepath.Join(repo.Path, "refs/"+head, branchName)
	if isFile(branchPath) {
		return ErrBranchExisted
	}

	f, err := os.Create(branchPath)
	if err != nil {
		return err
	}<commit_msg>Added GetRefs<commit_after>package git

import (
	"errors"
	"io"
	"os"
	"path/filepath"
	"strings"
)

var (
	ErrBranchExisted = errors.New("branch has existed")
)

func IsBranchExist(repoPath, branchName string) bool {
	branchPath := filepath.Join(repoPath, "refs/heads", branchName)
	return isFile(branchPath)
}

func (repo *Repository) IsBranchExist(branchName string) bool {
	branchPath := filepath.Join(repo.Path, "refs/heads", branchName)
	return isFile(branchPath)
}

func (repo *Repository) GetBranches() ([]string, error) {
	return repo.readRefDir("refs/heads", "")
}

func (repo *Repository) GetRefs() ([]string, error) {
	return repo.readRefDir("refs", "")
}

func (repo *Repository) CreateBranch(branchName, idStr string) error {
	return repo.createRef("heads", branchName, idStr)
}

func (repo *Repository) createRef(head, branchName, idStr string) error {
	id, err := NewIdFromString(idStr)
	if err != nil {
		return err
	}

	branchPath := filepath.Join(repo.Path, "refs/"+head, branchName)
	if isFile(branchPath) {
		return ErrBranchExisted
	}

	f, err := os.Create(branchPath)
	if err != nil {
		return err
	}
{'fraction_non_alphanumeric': 0.13921113689095127, 'fraction_numerical': 0.0, 'mean_word_length': 5.267441860465116, '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': '5646470', 'n_tokens_mistral': 774, 'n_tokens_neox': 761, 'n_words': 183}