repository/repo.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | package repository
import (
"context"
"errors"
"alin.ovh/erl/repository/git"
)
type Repo struct {
root string
kind RepoType
ignoreFileNames []string
}
var ErrNotRepo = errors.New("not a repository")
func GetRepo(ctx context.Context, wd string) (*Repo, error) {
var (
matches bool
root string
err error
)
matches, root, err = git.IsGitRepo(ctx, wd)
if err != nil {
return nil, err
}
if matches {
return &Repo{
root: root,
kind: Git,
ignoreFileNames: []string{".gitignore"},
}, nil
}
return nil, ErrNotRepo
}
func (r Repo) GetRoot() string {
return r.root
}
func (r Repo) GetKind() RepoType {
return r.kind
}
func (r Repo) GetIgnoreFileNames() []string {
return r.ignoreFileNames
}
|