<commit_before>package git

import (
	"errors"
	"regexp"
)

type GitRemote struct {
	Name string
	URL  string
}

func Remotes() ([]GitRemote, error) {
	r := regexp.MustCompile("(.+)\t(.+github.com.+) \\(push\\)")
	output, err := execGitCmd("remote", "-v")
	if err != nil {
		return nil, errors.New("Can't load git remote")
	}

	remotes := make([]GitRemote, 0)
	for _, o := range output {
		if r.MatchString(o) {
			match := r.FindStringSubmatch(o)
			remotes = append(remotes, GitRemote{Name: match[1], URL: match[2]})
		}
	}

	if len(remotes) == 0 {
		return nil, errors.New("Can't find git remote (push)")
	}

	return remotes, nil
}

func OriginRemote() (*GitRemote, error) {
	remotes, err := Remotes()
	if err != nil {
		return nil, err
	}

	for _, r := range remotes {
		if r.Name == "origin" {
			return &r, nil
		}
	}

	return nil, errors.New("Can't find git remote orign (push)")
}
<commit_msg>Use pointers to be more efficient<commit_after>package git

import (
	"errors"
	"regexp"
)

type GitRemote struct {
	Name string
	URL  string
}

func Remotes() ([]*GitRemote, error) {
	r := regexp.MustCompile("(.+)\t(.+github.com.+) \\(push\\)")
	output, err := execGitCmd("remote", "-v")
	if err != nil {
		return nil, errors.New("Can't load git remote")
	}

	remotes := make([]*GitRemote, 0)
	for _, o := range output {
		if r.MatchString(o) {
			match := r.FindStringSubmatch(o)
			remotes = append(remotes, &GitRemote{Name: match[1], URL: match[2]})
		}
	}

	if len(remotes) == 0 {
		return nil, errors.New("Can't find git remote (push)")
	}

	return remotes, nil
}

func OriginRemote() (*GitRemote, error) {
	remotes, err := Remotes()
	if err != nil {
		return nil, err
	}

	for _, r := range remotes {
		if r.Name == "origin" {
			return r, nil
		}
	}

	return nil, errors.New("Can't find git remote orign (push)")
}

{'fraction_non_alphanumeric': 0.17543859649122806, 'fraction_numerical': 0.0043859649122807015, 'mean_word_length': 3.517326732673267, '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': '7005778', 'n_tokens_mistral': 752, 'n_tokens_neox': 686, 'n_words': 191}