Skip to content

Commit

Permalink
Cleanup, return errs
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Sep 22, 2021
1 parent 745ed4c commit bc574b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
12 changes: 4 additions & 8 deletions tui/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bc574b7

Please sign in to comment.