diff options
| author | Jeff Carr <[email protected]> | 2024-12-13 16:18:25 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-13 16:18:25 -0600 |
| commit | 2574ec733a812a747b3e4075f8affc862453034f (patch) | |
| tree | bbdfe741b3cfb90338de71a3e92557de6b6664a3 /shell.go | |
| parent | d7a90a71ab44e85c5abef44ad312e791f1254e71 (diff) | |
IsLocalBranch()
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 { |
