Skip to content

Commit

Permalink
fix(ui): spinner regression & empty repo
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 2, 2023
1 parent c0b9c0d commit 04038e7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
12 changes: 5 additions & 7 deletions ui/pages/repo/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ package repo

import (
"fmt"
"strings"

"github.com/charmbracelet/soft-serve/server/config"
"github.com/charmbracelet/soft-serve/ui/common"
)

func defaultEmptyRepoMsg(cfg *config.Config, repo string) string {
publicURL := cfg.SSH.PublicURL
repo = strings.TrimSuffix(repo, ".git")
return fmt.Sprintf(`# Quick Start
Get started by cloning this repository, add your files, commit, and push.
## Clone this repository.
`+"```"+`sh
git clone %[1]s/%[2]s.git
git clone %[1]s
`+"```"+`
## Creating a new repository on the command line
Expand All @@ -28,15 +26,15 @@ git init
git add README.md
git branch -M main
git commit -m "first commit"
git remote add origin %[1]s/%[2]s.git
git remote add origin %[1]s
git push -u origin main
`+"```"+`
## Pushing an existing repository from the command line
`+"```"+`sh
git remote add origin %[1]s/%[2]s.git
git remote add origin %[1]s
git push -u origin main
`+"```"+`
`, publicURL, repo)
`, common.RepoURL(cfg.SSH.PublicURL, repo))
}
5 changes: 1 addition & 4 deletions ui/pages/repo/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ func (r *Readme) updateReadmeCmd() tea.Msg {
if r.repo == nil {
return common.ErrorCmd(common.ErrMissingRepo)
}
rm, rp, err := backend.Readme(r.repo)
if err != nil {
return common.ErrorCmd(err)
}
rm, rp, _ := backend.Readme(r.repo)
r.readmePath = rp
r.code.GotoTop()
cmd := r.code.SetContent(rm, rp)
Expand Down
7 changes: 4 additions & 3 deletions ui/pages/repo/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,12 @@ func UpdateRefCmd(repo backend.Repository) tea.Cmd {
if err != nil {
return common.ErrorMsg(err)
}
bs, _ := r.Branches()
if len(bs) == 0 {
return EmptyRepoMsg{}
}
ref, err := r.HEAD()
if err != nil {
if bs, err := r.Branches(); err != nil && len(bs) == 0 {
return EmptyRepoMsg{}
}
logger.Debugf("ui: error getting HEAD reference: %v", err)
return common.ErrorMsg(err)
}
Expand Down
1 change: 1 addition & 0 deletions ui/pages/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
r.tabs.Init(),
// This will set the selected repo in each pane's model.
r.updateModels(msg),
r.spinner.Tick,
)
case RefMsg:
r.ref = msg
Expand Down
2 changes: 1 addition & 1 deletion ui/styles/styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func DefaultStyles() *Styles {

s.NoContent = lipgloss.NewStyle().
SetString("No Content.").
MarginTop(2).
MarginTop(1).
MarginLeft(2).
Foreground(lipgloss.Color("242"))

Expand Down

0 comments on commit 04038e7

Please sign in to comment.