File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,14 @@ import (
1010 tea "github.com/charmbracelet/bubbletea"
1111)
1212
13- type repoMsg struct {
14- repo repo
15- }
1613type repo struct {
1714 path string
1815 status string
1916}
2017
2118var excludeDirs = regexp .MustCompile (`.+/(\..+|node_modules)` ) // Skip hidden directories (incl. .git) and node_modules
2219
23- func getRepos (path string , sub chan repoMsg ) tea.Cmd {
20+ func getRepos (path string , sub chan repo ) tea.Cmd {
2421 return func () tea.Msg {
2522 path , err := filepath .Abs (path )
2623 if err != nil {
@@ -48,7 +45,7 @@ func getRepos(path string, sub chan repoMsg) tea.Cmd {
4845 gi .Parse (buf )
4946
5047 if ! gi .IsClean () {
51- sub <- repoMsg { repo : repo {path : repopath , status : gi .Summary ()} }
48+ sub <- repo {path : repopath , status : gi .Summary ()}
5249 }
5350 }
5451 return fs .SkipDir
@@ -61,9 +58,3 @@ func getRepos(path string, sub chan repoMsg) tea.Cmd {
6158 return doneMsg {}
6259 }
6360}
64-
65- func waitForRepoStatus (sub chan repoMsg ) tea.Cmd {
66- return func () tea.Msg {
67- return repoMsg (<- sub )
68- }
69- }
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ import (
1212
1313var docStyle = lipgloss .NewStyle ().Margin (1 , 2 )
1414
15+ type repoMsg struct {
16+ repo
17+ }
1518type doneMsg struct {}
1619type errMsg error
1720
@@ -31,7 +34,7 @@ func (r repo) FilterValue() string {
3134type model struct {
3235 list list.Model
3336 path string
34- sub chan repoMsg
37+ sub chan repo
3538 quitting bool
3639 err error
3740}
@@ -91,7 +94,14 @@ func initialModel(wd string) tea.Model {
9194 l .SetSpinner (spinner .MiniDot )
9295 l .SetStatusBarItemName ("repository" , "repositories" )
9396 l .ToggleSpinner ()
94- return model {list : l , path : wd , sub : make (chan repoMsg )}
97+ return model {list : l , path : wd , sub : make (chan repo )}
98+ }
99+
100+ func waitForRepoStatus (sub chan repo ) tea.Cmd {
101+ return func () tea.Msg {
102+ repo := <- sub
103+ return repoMsg (repoMsg {repo : repo })
104+ }
95105}
96106
97107func openEditor (path string ) tea.Cmd {
You can’t perform that action at this time.
0 commit comments