summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
Diffstat (limited to 'shell.go')
-rw-r--r--shell.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/shell.go b/shell.go
index 8215d46..efb682d 100644
--- a/shell.go
+++ b/shell.go
@@ -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 {