all repos — erl @ d29d0816680a343ee47c40fa9ace8d80862ac412

Execute Reload Loop

feat: apply ignores from .gitignore/.ignore files

Alan Pearce
commit

d29d0816680a343ee47c40fa9ace8d80862ac412

parent

a52be32962b55478c31d6f4e1139e4ab4b140100

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 +}