-
Notifications
You must be signed in to change notification settings - Fork 882
Description
First of all: Thanks for this project! It's been a very good experience so far!
I took me some time to understand why my url insteadOf rules are not applied to higher level Clone()/PlainClone() commands. As far as I understood insteadOf rules are only applied to existing repositories on .git/config remotes. On my journey through the project I didn't find any reason to not apply global url insteadOf rules (i.e. defined in .gitconfig) to higher level Clone()/PlainClone() functions. I am using something like this:
cloneOpts := &git.CloneOptions{
URL: repoURL,
}
conf, err := config.LoadConfig(config.GlobalScope)
if err != nil {
return err
}
// URL replacements would need to be done manually here
storer := memory.NewStorage()
err = storer.SetConfig(conf)
if err != nil {
return err
}
fs := memfs.New()
repo, err := git.Clone(storer, fs, cloneOpts)
if err != nil {
return errors.Wrapf(err, "clone repository '%s'", repoURL)
}
This code won't apply any insteadOf rules from my global config. Am I overlooking something or could url replacement be added to something like: func (r *Repository) CreateRemote(c *config.RemoteConfig) (*Remote, error)?
Thanks for suggestions and hints.