fix(ui): spinner regression & empty repo

Ayman Bagabas created

Change summary

ui/pages/repo/empty.go  | 12 +++++-------
ui/pages/repo/readme.go |  5 +----
ui/pages/repo/refs.go   |  7 ++++---
ui/pages/repo/repo.go   |  1 +
ui/styles/styles.go     |  2 +-
5 files changed, 12 insertions(+), 15 deletions(-)

Detailed changes

ui/pages/repo/empty.go 🔗

@@ -2,14 +2,12 @@ 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.
@@ -17,7 +15,7 @@ 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
@@ -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))
 }

ui/pages/repo/readme.go 🔗

@@ -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)

ui/pages/repo/refs.go 🔗

@@ -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)
 		}

ui/pages/repo/repo.go 🔗

@@ -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

ui/styles/styles.go 🔗

@@ -413,7 +413,7 @@ func DefaultStyles() *Styles {
 
 	s.NoContent = lipgloss.NewStyle().
 		SetString("No Content.").
-		MarginTop(2).
+		MarginTop(1).
 		MarginLeft(2).
 		Foreground(lipgloss.Color("242"))