summaryrefslogtreecommitdiff
path: root/shell.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-13 16:18:25 -0600
committerJeff Carr <[email protected]>2024-12-13 16:18:25 -0600
commit2574ec733a812a747b3e4075f8affc862453034f (patch)
treebbdfe741b3cfb90338de71a3e92557de6b6664a3 /shell.go
parentd7a90a71ab44e85c5abef44ad312e791f1254e71 (diff)
IsLocalBranch()
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 {