Files
lpm/state/repository_factory.go
zeekay 7d7127a687 deps: update to latest luxfi packages
- Update node v1.16.15 → v1.19.8
- Update crypto v1.17.0 → v1.17.4
- Update database v1.2.0 → v1.2.1
- Update geth v1.16.34 → v1.16.35
- Update ids v1.1.0 → v1.1.1
- Update Go 1.25 → 1.25.1
- Update copyright year to 2025
2025-09-30 00:05:18 +00:00

43 lines
926 B
Go

// Copyright (C) 2019-2025, Lux Partners Limited. All rights reserved.
// See the file LICENSE for licensing terms.
package state
import (
"os"
"path/filepath"
"github.com/luxfi/lpm/git"
)
var _ RepositoryFactory = repositoryFactory{}
type RepositoryFactory interface {
GetRepository(alias string) (Repository, error)
}
func NewRepositoryFactory(reposPath string) RepositoryFactory {
return &repositoryFactory{
reposPath: reposPath,
git: git.RepositoryFactory{},
}
}
type repositoryFactory struct {
reposPath string
git git.Factory
}
func (r repositoryFactory) GetRepository(alias string) (Repository, error) {
path := filepath.Join(r.reposPath, alias)
// check that this is a valid path on disk before we return it to be used
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, err
}
return &DiskRepository{
Git: r.git,
Path: filepath.Join(r.reposPath, alias),
}, nil
}