<commit_before>package deploy_docus

import (
	"fmt"
	"strings"
)

type Repository struct {
	Id          int64
	Origin      string
	Destination string

	Rsa *Rsa
}

func (r *Repository) Name() string {
	suffix := "<EMAIL>:"
	affix := ".git"
	name := r.Origin[len(suffix) : len(r.Origin)-len(affix)]

	return strings.Replace(name, "/", "_", 1)
}

func (r *Repository) LocalPath() string {
	return fmt.Sprintf("/tmp/%s", r.Name())
}

func CreateRepository(origin string, destination string, rsa_key []byte) (*Repository, error) {
	db, err := GetDbConnection()
	if err != nil {
		return nil, err
	}

	command := `INSERT INTO repositories (origin, destination, rsa_key) VALUES ($1, $2, $3) RETURNING id;`
	var id int64
	err = db.QueryRow(command, origin, destination, rsa_key).Scan(&id)
	if err != nil {
		return nil, err
	}

	repository := &Repository{
		Id:          id,
		Origin:      origin,
		Destination: destination,
	}
	repository.Rsa = NewRsa(repository, rsa_key)

	return repository, nil
}

func FindRepository(id int64) (*Repository, error) {
	db, err := GetDbConnection()
	if err != nil {
		return nil, err
	}

	var origin string
	var destination string
	var rsa_key []byte
	err = db.QueryRow("SELECT origin, destination, rsa_key FROM repositories WHERE id = $1", id).Scan(&origin, &destination, &rsa_key)
	if err != nil {
		return nil, err
	}

	repository := &Repository{
		Id:          id,
		Origin:      origin,
		Destination: destination,
	}
	repository.Rsa = NewRsa(repository, rsa_key)

	return repository, nil
}<commit_msg>avoid duplicating instantiating a new repository<commit_after>package deploy_docus

import (
	"fmt"
	"strings"
)

type Repository struct {
	Id          int64
	Origin      string
	Destination string

	Rsa *Rsa
}

func (r *Repository) Name() string {
	suffix := "<EMAIL>:"
	affix := ".git"
	name := r.Origin[len(suffix) : len(r.Origin)-len(affix)]

	return strings.Replace(name, "/", "_", 1)
}

func (r *Repository) LocalPath() string {
	return fmt.Sprintf("/tmp/%s", r.Name())
}

func BuildRepository(id int64, origin string, destination string, rsa_key []byte) *Repository {
	repository := &Repository{
		Id:          id,
		Origin:      origin,
		Destination: destination,
	}
	repository.Rsa = NewRsa(repository, rsa_key)
	return repository
}

func CreateRepository(origin string, destination string, rsa_key []byte) (*Repository, error) {
	db, err := GetDbConnection()
	if err != nil {
		return nil, err
	}

	var id int64
	err = db.QueryRow(`INSERT INTO repositories (origin, destination, rsa_key) VALUES ($1, $2, $3) RETURNING id;`, origin, destination, rsa_key).Scan(&id)
	if err != nil {
		return nil, err
	}

	return BuildRepository(id, origin, destination, rsa_key), nil
}

func FindRepository(id int64) (*Repository, error) {
	db, err := GetDbConnection()
	if err != nil {
		return nil, err
	}

	var origin string
	var destination string
	var rsa_key []byte
	err = db.QueryRow("SELECT origin, destination, rsa_key FROM repositories WHERE id = $1", id).Scan(&origin, &destination, &rsa_key)
	if err != nil {
		return nil, err
	}

	return BuildRepository(id, origin, destination, rsa_key), nil
}
{'fraction_non_alphanumeric': 0.1325685149776928, 'fraction_numerical': 0.0076481835564053535, 'mean_word_length': 3.9825396825396826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5158446', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1054, 'n_words': 318}