4392caaeceef1ca3cd204321271ad3672af13727
- Author
- Ayman Bagabas <ayman.bagabas@gmail.com>
- Committer
- Ayman Bagabas <ayman.bagabas@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/internal/config/config.go b/internal/config/config.go
2index 2b1ad55c368bfb1e57b0ab0f5591910d02430de6..eb6d3bcc907921df387c24f3917cc93a2476ecf7 100644
3--- a/internal/config/config.go
4+++ b/internal/config/config.go
5@@ -152,7 +152,7 @@ func (cfg *Config) createDefaultConfigRepo(yaml string) error {
6 if err != nil {
7 return err
8 }
9- wt, err := cr.Repository.Worktree()
10+ wt, err := cr.Repository().Worktree()
11 if err != nil {
12 return err
13 }
14@@ -190,7 +190,7 @@ func (cfg *Config) createDefaultConfigRepo(yaml string) error {
15 if err != nil {
16 return err
17 }
18- err = cr.Repository.Push(&gg.PushOptions{})
19+ err = cr.Repository().Push(&gg.PushOptions{})
20 if err != nil {
21 return err
22 }
23diff --git a/internal/git/git.go b/internal/git/git.go
24index 02b9ac6ef6146a09669aced9885c213f87eb09db..fe21bc782178d12a2c7a1de240fe87a4d351fe1c 100644
25--- a/internal/git/git.go
26+++ b/internal/git/git.go
27@@ -7,7 +7,6 @@ import (
28 "path/filepath"
29 "sort"
30 "sync"
31- "time"
32
33 gitypes "github.com/charmbracelet/soft-serve/internal/tui/bubbles/git/types"
34 "github.com/go-git/go-billy/v5/memfs"
35@@ -23,28 +22,27 @@ var ErrMissingRepo = errors.New("missing repo")
36
37 // Repo represents a Git repository.
38 type Repo struct {
39- Name string
40- Repository *git.Repository
41- Readme string
42- LastUpdated *time.Time
43- refCommits map[plumbing.Hash]gitypes.Commits
44- ref *plumbing.Reference
45- refs []*plumbing.Reference
46+ name string
47+ repository *git.Repository
48+ Readme string
49+ refCommits map[plumbing.Hash]gitypes.Commits
50+ head *plumbing.Reference
51+ refs []*plumbing.Reference
52 }
53
54 // GetName returns the name of the repository.
55-func (r *Repo) GetName() string {
56- return r.Name
57+func (r *Repo) Name() string {
58+ return r.name
59 }
60
61 // GetHEAD returns the reference for a repository.
62 func (r *Repo) GetHEAD() *plumbing.Reference {
63- return r.ref
64+ return r.head
65 }
66
67 // SetHEAD sets the repository head reference.
68 func (r *Repo) SetHEAD(ref *plumbing.Reference) error {
69- r.ref = ref
70+ r.head = ref
71 return nil
72 }
73
74@@ -53,8 +51,8 @@ func (r *Repo) GetReferences() []*plumbing.Reference {
75 }
76
77 // GetRepository returns the underlying go-git repository object.
78-func (r *Repo) GetRepository() *git.Repository {
79- return r.Repository
80+func (r *Repo) Repository() *git.Repository {
81+ return r.repository
82 }
83
84 // Tree returns the git tree for a given path.
85@@ -64,7 +62,7 @@ func (r *Repo) Tree(ref *plumbing.Reference, path string) (*object.Tree, error)
86 if err != nil {
87 return nil, err
88 }
89- c, err := r.Repository.CommitObject(hash)
90+ c, err := r.repository.CommitObject(hash)
91 if err != nil {
92 return nil, err
93 }
94@@ -89,9 +87,9 @@ func (r *Repo) GetCommits(ref *plumbing.Reference) (gitypes.Commits, error) {
95 if ok {
96 return commits, nil
97 }
98- log.Printf("caching commits for %s/%s: %s", r.Name, ref.Name(), ref.Hash())
99+ log.Printf("caching commits for %s/%s: %s", r.name, ref.Name(), ref.Hash())
100 commits = gitypes.Commits{}
101- co, err := r.Repository.CommitObject(hash)
102+ co, err := r.repository.CommitObject(hash)
103 if err != nil {
104 return nil, err
105 }
106@@ -124,7 +122,7 @@ func (r *Repo) targetHash(ref *plumbing.Reference) (plumbing.Hash, error) {
107 return plumbing.ZeroHash, plumbing.ErrInvalidType
108 }
109 if ref.Name().IsTag() {
110- to, err := r.Repository.TagObject(hash)
111+ to, err := r.repository.TagObject(hash)
112 switch err {
113 case nil:
114 // annotated tag (object has a target hash)
115@@ -145,7 +143,7 @@ func (r *Repo) loadCommits(ref *plumbing.Reference) (gitypes.Commits, error) {
116 if err != nil {
117 return nil, err
118 }
119- l, err := r.Repository.Log(&git.LogOptions{
120+ l, err := r.repository.Log(&git.LogOptions{
121 Order: git.LogOrderCommitterTime,
122 From: hash,
123 })
124@@ -204,7 +202,7 @@ func (rs *RepoSource) GetRepo(name string) (*Repo, error) {
125 rs.mtx.Lock()
126 defer rs.mtx.Unlock()
127diff --git a/internal/tui/bubbles/git/bubble.go b/internal/tui/bubbles/git/bubble.go
128index d9258b70196158d6c1a83d1bb12acb3befbadf7c..a6ed04a1dac63bd1edda771cb0262c254b88f1f4 100644
129--- a/internal/tui/bubbles/git/bubble.go
130+++ b/internal/tui/bubbles/git/bubble.go
131@@ -65,7 +65,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
132 cmds := make([]tea.Cmd, 0)
133 switch msg := msg.(type) {
134 case tea.KeyMsg:
135- if b.repo.GetName() != "config" {
136+ if b.repo.Name() != "config" {
137 switch msg.String() {
138 case "R":
139 b.state = aboutPage
140@@ -109,7 +109,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
141 func (b *Bubble) Help() []types.HelpEntry {
142 h := []types.HelpEntry{}
143 h = append(h, b.boxes[b.state].(types.BubbleHelper).Help()...)
144- if b.repo.GetName() != "config" {
145+ if b.repo.Name() != "config" {
146 h = append(h, types.HelpEntry{"R", "readme"})
147 h = append(h, types.HelpEntry{"F", "files"})
148 h = append(h, types.HelpEntry{"C", "commits"})
149diff --git a/internal/tui/bubbles/git/types/git.go b/internal/tui/bubbles/git/types/git.go
150index a4b78b91fe3d7f2467b8e50553d5f771b27ae16f..de6bfd1aae84e81306a3da20ee389075189cab18 100644
151--- a/internal/tui/bubbles/git/types/git.go
152+++ b/internal/tui/bubbles/git/types/git.go
153@@ -7,13 +7,13 @@ import (
154 )
155
156 type Repo interface {
157- GetName() string
158+ Name() string
159 GetHEAD() *plumbing.Reference
160 SetHEAD(*plumbing.Reference) error
161 GetReferences() []*plumbing.Reference
162 GetReadme() string
163 GetCommits(*plumbing.Reference) (Commits, error)
164- GetRepository() *git.Repository
165+ Repository() *git.Repository
166 Tree(*plumbing.Reference, string) (*object.Tree, error)
167 }
168
169diff --git a/internal/tui/commands.go b/internal/tui/commands.go
170index 4a6f34507b22c3141a6035951e90f5c133cacb8c..7eef46ba64f531f04173c8bdb047dec0e69a17d7 100644
171--- a/internal/tui/commands.go
172+++ b/internal/tui/commands.go
173@@ -75,17 +75,18 @@ func (b *Bubble) menuEntriesFromSource() ([]MenuEntry, error) {
174 }
175 for _, r := range b.config.Source.AllRepos() {
176 var found bool
177+ rn := r.Name()
178 for _, me := range mes {
179- if me.Repo == r.Name {
180+ if me.Repo == rn {
181 found = true
182 }
183 }
184 if !found {
185- acc := b.config.AuthRepo(r.Name, b.session.PublicKey())
186+ acc := b.config.AuthRepo(rn, b.session.PublicKey())
187 if acc == gm.NoAccess {
188 continue
189 }
190- me, err := b.newMenuEntry(r.Name, r.Name)
191+ me, err := b.newMenuEntry(rn, rn)
192 if err != nil {
193 return nil, err
194 }
195diff --git a/server/middleware.go b/server/middleware.go
196index faa9959692585ee67741b7aea4bad9e9f5c895a9..1ef8759411c81131941e45180965849e752bc435 100644
197--- a/server/middleware.go
198+++ b/server/middleware.go
199@@ -36,7 +36,7 @@ func softServeMiddleware(ac *appCfg.Config) wish.Middleware {
200 }
201 repoExists := false
202 for _, rp := range ac.Source.AllRepos() {
203- if rp.Name == repo {
204+ if rp.Name() == repo {
205 repoExists = true
206 }
207 }
208@@ -62,7 +62,7 @@ func softServeMiddleware(ac *appCfg.Config) wish.Middleware {
209 _ = s.Exit(1)
210 return
211 }
212- fc, err := readFile(rs.Repository, strings.Join(ps[1:], "/"))
213+ fc, err := readFile(rs.Repository(), strings.Join(ps[1:], "/"))
214 if err != nil {
215 _, _ = s.Write([]byte(err.Error()))
216 _ = s.Exit(1)