Diff
1diff --git a/cmd/soft/browse/browse.go b/cmd/soft/browse/browse.go
2index 43fa3e612036eaa0e36908cac09a9923cf51f366..ff1a1d06178a3c6775f3da7d6f1127c0bfa45c56 100644
3--- a/cmd/soft/browse/browse.go
4+++ b/cmd/soft/browse/browse.go
5@@ -43,6 +43,7 @@ var Command = &cobra.Command{
6 output := termenv.DefaultOutput()
7 ctx := cmd.Context()
8 c := common.NewCommon(ctx, output, 0, 0)
9+ c.HideCloneCmd = true
10 comps := []common.TabComponent{
11 repo.NewReadme(c),
12 repo.NewFiles(c),
13@@ -69,12 +70,6 @@ var Command = &cobra.Command{
14 },
15 }
16
17-func init() {
18- // HACK: This is a hack to hide the clone url
19- // TODO: Make this configurable
20- common.CloneCmd = func(publicURL, name string) string { return "" }
21-}
22-
23 type state int
24
25 const (
26diff --git a/pkg/ui/common/common.go b/pkg/ui/common/common.go
27index 3a236215055e3f40d971a2c89393a99fd9aca03c..ceee1f58ef0cee0ae55bf61299a6286da003d66e 100644
28--- a/pkg/ui/common/common.go
29+++ b/pkg/ui/common/common.go
30@@ -2,6 +2,7 @@ package common
31
32 import (
33 "context"
34+ "fmt"
35
36 "github.com/charmbracelet/log"
37 "github.com/charmbracelet/soft-serve/git"
38@@ -33,6 +34,7 @@ type Common struct {
39 Zone *zone.Manager
40 Output *termenv.Output
41 Logger *log.Logger
42+ HideCloneCmd bool
43 }
44
45 // NewCommon returns a new Common struct.
46@@ -95,3 +97,11 @@ func (c *Common) PublicKey() ssh.PublicKey {
47 }
48 return nil
49 }
50+
51+// CloneCmd returns the clone command string.
52+func (c *Common) CloneCmd(publicURL, name string) string {
53+ if c.HideCloneCmd {
54+ return ""
55+ }
56+ return fmt.Sprintf("git clone %s", RepoURL(publicURL, name))
57+}
58diff --git a/pkg/ui/common/utils.go b/pkg/ui/common/utils.go
59index 08f07ada1e7c32ce4e44b3d605b1a39e5f77036e..dac9ac2f07fb2cd49c2ad92ffe2b0ee03f7c491a 100644
60--- a/pkg/ui/common/utils.go
61+++ b/pkg/ui/common/utils.go
62@@ -33,8 +33,3 @@ func RepoURL(publicURL, name string) string {
63
64 return fmt.Sprintf("%s/%s", publicURL, name)
65 }
66-
67-// CloneCmd returns the URL of the repository.
68-var CloneCmd = func(publicURL, name string) string {
69- return fmt.Sprintf("git clone %s", RepoURL(publicURL, name))
70-}
71diff --git a/pkg/ui/pages/repo/repo.go b/pkg/ui/pages/repo/repo.go
72index cc4ba58d8fa6c0eeeb2242a522208860a726627c..fb5f0a603c587e2610a86c4a5558246dc011bb2f 100644
73--- a/pkg/ui/pages/repo/repo.go
74+++ b/pkg/ui/pages/repo/repo.go
75@@ -174,7 +174,7 @@ func (r *Repo) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
76 }
77 if r.selectedRepo != nil {
78 urlID := fmt.Sprintf("%s-url", r.selectedRepo.Name())
79- cmd := common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
80+ cmd := r.common.CloneCmd(r.common.Config().SSH.PublicURL, r.selectedRepo.Name())
81 if msg, ok := msg.(tea.MouseMsg); ok && r.common.Zone.Get(urlID).InBounds(msg) {
82 cmds = append(cmds, copyCmd(cmd, "Command copied to clipboard"))
83 }
84@@ -329,7 +329,7 @@ func (r *Repo) headerView() string {
85 Align(lipgloss.Right)
86 var url string
87 if cfg := r.common.Config(); cfg != nil {
88- url = common.CloneCmd(cfg.SSH.PublicURL, r.selectedRepo.Name())
89+ url = r.common.CloneCmd(cfg.SSH.PublicURL, r.selectedRepo.Name())
90 }
91 url = common.TruncateString(url, r.common.Width-lipgloss.Width(desc)-1)
92 url = r.common.Zone.Mark(
93diff --git a/pkg/ui/pages/selection/item.go b/pkg/ui/pages/selection/item.go
94index f90f58d8ce005336248920dcda2e7a3ebf3a987c..4a6209dcf044acb177a135fb970285f6172a691b 100644
95--- a/pkg/ui/pages/selection/item.go
96+++ b/pkg/ui/pages/selection/item.go
97@@ -11,7 +11,6 @@ import (
98 "github.com/charmbracelet/bubbles/list"
99 tea "github.com/charmbracelet/bubbletea"
100 "github.com/charmbracelet/lipgloss"
101- "github.com/charmbracelet/soft-serve/pkg/config"
102 "github.com/charmbracelet/soft-serve/pkg/proto"
103 "github.com/charmbracelet/soft-serve/pkg/ui/common"
104 "github.com/dustin/go-humanize"
105@@ -54,16 +53,20 @@ type Item struct {
106 }
107
108 // New creates a new Item.
109-func NewItem(repo proto.Repository, cfg *config.Config) (Item, error) {
110+func NewItem(c common.Common, repo proto.Repository) (Item, error) {
111 var lastUpdate *time.Time
112 lu := repo.UpdatedAt()
113 if !lu.IsZero() {
114 lastUpdate = &lu
115 }
116+ var cmd string
117+ if cfg := c.Config(); cfg != nil {
118+ cmd = c.CloneCmd(cfg.SSH.PublicURL, repo.Name())
119+ }
120 return Item{
121 repo: repo,
122 lastUpdate: lastUpdate,
123- cmd: common.CloneCmd(cfg.SSH.PublicURL, repo.Name()),
124+ cmd: cmd,
125 }, nil
126 }
127
128diff --git a/pkg/ui/pages/selection/selection.go b/pkg/ui/pages/selection/selection.go
129index 2638ff16a7e8cd353eb8c871c1b388a613f3c5e2..4b9b72a17ddd5ea0c37e2622f26f53e0b6b08567 100644
130--- a/pkg/ui/pages/selection/selection.go
131+++ b/pkg/ui/pages/selection/selection.go
132@@ -215,7 +215,7 @@ func (s *Selection) Init() tea.Cmd {
133 }
134 al := be.AccessLevelByPublicKey(ctx, r.Name(), pk)
135 if al >= access.ReadOnlyAccess {
136- item, err := NewItem(r, cfg)
137+ item, err := NewItem(s.common, r)
138 if err != nil {
139 s.common.Logger.Debugf("ui: failed to create item for %s: %v", r.Name(), err)
140 continue