<commit_before>package lfsapi

import (
	"fmt"
	"net/url"
	"os"
	"path"
	"strings"
	"sync"

	"github.com/git-lfs/git-lfs/git"
	"github.com/rubyist/tracerx"
)

type Access string

const (
	NoneAccess      Access = "none"
	BasicAccess     Access = "basic"
	PrivateAccess   Access = "private"
	NegotiateAccess Access = "negotiate"
	NTLMAccess      Access = "ntlm"
	emptyAccess     Access = ""
	defaultRemote          = "origin"
)

type EndpointFinder interface {
	NewEndpointFromCloneURL(rawurl string) Endpoint
	NewEndpoint(rawurl string) Endpoint
	Endpoint(operation, remote string) Endpoint
	RemoteEndpoint(operation, remote string) Endpoint
	GitRemoteURL(remote string, forpush bool) string
	AccessFor(rawurl string) Access
	SetAccess(rawurl string, access Access)
	GitProtocol() string
}

type endpointGitFinder struct {
	git         Env
	gitProtocol string

	aliasMu sync.Mutex
	aliases map[string]string

	accessMu  sync.Mutex
	urlAccess map[string]Access
}

func NewEndpointFinder(git Env) EndpointFinder {
	e := &endpointGitFinder{
		gitProtocol: "https",
		aliases:     make(map[string]string),
		urlAccess:   make(map[string]Access),
	}

	if git != nil {
		e.git = git
		if v, ok := git.Get("lfs.gitprotocol"); ok {
			e.gitProtocol = v
		}
		initAliases(e, git)
	}

	return e
}

func (e *endpointGitFinder) Endpoint(operation, remote string) Endpoint {
	ep := e.getEndpoint(operation, remote)
	ep.Operation = operation
	return ep
}

func (e *endpointGitFinder) getEndpoint(operation, remote string) Endpoint {
	if e.git == nil {
		return Endpoint{}
	}
<commit_msg>lfsapi/endpoint_finder: initialize `*config.URLConfig` instance on `*endpointGitFinder`<commit_after>package lfsapi

import (
	"fmt"
	"net/url"
	"os"
	"path"
	"strings"
	"sync"

	"github.com/git-lfs/git-lfs/config"
	"github.com/git-lfs/git-lfs/git"
	"github.com/rubyist/tracerx"
)

type Access string

const (
	NoneAccess      Access = "none"
	BasicAccess     Access = "basic"
	PrivateAccess   Access = "private"
	NegotiateAccess Access = "negotiate"
	NTLMAccess      Access = "ntlm"
	emptyAccess     Access = ""
	defaultRemote          = "origin"
)

type EndpointFinder interface {
	NewEndpointFromCloneURL(rawurl string) Endpoint
	NewEndpoint(rawurl string) Endpoint
	Endpoint(operation, remote string) Endpoint
	RemoteEndpoint(operation, remote string) Endpoint
	GitRemoteURL(remote string, forpush bool) string
	AccessFor(rawurl string) Access
	SetAccess(rawurl string, access Access)
	GitProtocol() string
}

type endpointGitFinder struct {
	git         Env
	gitProtocol string

	aliasMu sync.Mutex
	aliases map[string]string

	accessMu  sync.Mutex
	urlAccess map[string]Access
	urlConfig *config.URLConfig
}

func NewEndpointFinder(git Env) EndpointFinder {
	e := &endpointGitFinder{
		gitProtocol: "https",
		aliases:     make(map[string]string),
		urlAccess:   make(map[string]Access),
	}

	if git != nil {
		e.git = git
		e.urlConfig = config.NewURLConfig(e.git)
		if v, ok := git.Get("lfs.gitprotocol"); ok {
			e.gitProtocol = v
		}
		initAliases(e, git)
	}

	return e
}

func (e *endpointGitFinder) Endpoint(operation, remote string) Endpoint {
	ep := e.getEndpoint(operation, remote)
	ep.Operation = operation
	return ep
}

func (e *endpointGitFinder) getEndpoint(operation, remote string) Endpoint {
	if e.git == nil {
		return Endpoint{}
	}

{'fraction_non_alphanumeric': 0.10483628717332533, 'fraction_numerical': 0.0, 'mean_word_length': 4.235849056603773, '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': '5597857', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1151, 'n_words': 278}