From bc574b748ea18366bab7bb81234e20c69dcfa3aa Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 22 Sep 2021 17:29:41 -0400 Subject: [PATCH] Cleanup, return errs --- git/git.go | 4 ++-- tui/session.go | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/git/git.go b/git/git.go index 748678f98..074cbf83b 100644 --- a/git/git.go +++ b/git/git.go @@ -154,11 +154,11 @@ func (r *Repo) LatestFile(path string) (string, error) { } f, err := c.File(path) if err != nil { - return "", nil + return "", err } content, err := f.Contents() if err != nil { - return "", nil + return "", err } return content, nil } diff --git a/tui/session.go b/tui/session.go index 648307358..78ed852cd 100644 --- a/tui/session.go +++ b/tui/session.go @@ -22,9 +22,7 @@ func SessionHandler(reposPath string, repoPoll time.Duration) func(ssh.Session) } appCfg, err := loadConfig(rs) if err != nil { - if err != nil { - log.Printf("cannot load config: %s", err) - } + log.Printf("cannot load config: %s", err) } return func(s ssh.Session) (tea.Model, []tea.ProgramOption) { @@ -38,9 +36,7 @@ func SessionHandler(reposPath string, repoPoll time.Duration) func(ssh.Session) } cfg, err := loadConfig(rs) if err != nil { - if err != nil { - log.Printf("cannot load config: %s", err) - } + log.Printf("cannot load config: %s", err) } appCfg = cfg log.Printf("Repo bubble loaded in %s", time.Since(ct)) @@ -70,11 +66,11 @@ func loadConfig(rs *git.RepoSource) (*Config, error) { cfg.RepoSource = rs cr, err := rs.GetRepo("config") if err != nil { - return nil, fmt.Errorf("cannot load config repo: %s", err) + return nil, err } cs, err := cr.LatestFile("config.json") if err != nil { - return nil, fmt.Errorf("cannot load config.json: %s", err) + return nil, err } err = json.Unmarshal([]byte(cs), cfg) if err != nil {