diff options
Diffstat (limited to 'shell.go')
| -rw-r--r-- | shell.go | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -79,12 +79,29 @@ func (repo *Repo) Exists(filename string) bool { } func (repo *Repo) IsValid() bool { - if !repo.IsDirectory() { + if repo == nil { + return false + } + if !repo.IsGitDirectory() { return false } return true } +func (repo *Repo) ReadFile(fname string) ([]byte, error) { + fullname := filepath.Join(repo.FullPath, fname) + return os.ReadFile(fullname) +} + +func (repo *Repo) IsGitDirectory() bool { + gitdir := filepath.Join(repo.FullPath, ".git") + info, err := os.Stat(gitdir) + if err != nil { + return false + } + return info.IsDir() +} + func (repo *Repo) IsDirectory() bool { info, err := os.Stat(repo.FullPath) if err != nil { |
