feat: apply ignores from .gitignore/.ignore files
1 file changed, 51 insertions(+), 0 deletions(-)
changed files
A repository/repo.go
@@ -0,0 +1,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 +}