Skip to content

Commit a25c090

Browse files
authored
Merge pull request #5 from thetnaingtn/tui-improvement
TUI Improvement
2 parents 69fe70a + 9c9829f commit a25c090

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

forky.go

+22-20
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ var (
1515
)
1616

1717
type RepositoryWithDetails struct {
18-
Owner string
19-
Name string
20-
FullName string
21-
Description string
22-
RepoURL string
23-
DefaultBranch string
24-
Parent string
25-
ParentDeleted bool
26-
Private bool
27-
BehindBy int
18+
Owner string
19+
Name string
20+
FullName string
21+
Description string
22+
RepoURL string
23+
DefaultBranch string
24+
Parent string
25+
ParentFullName string
26+
ParentDeleted bool
27+
Private bool
28+
BehindBy int
2829
}
2930

3031
func GetForks(ctx context.Context, client *github.Client) ([]*RepositoryWithDetails, error) {
@@ -103,16 +104,17 @@ func SyncBranchWithUpstreamRepo(client *github.Client, repo *RepositoryWithDetai
103104

104105
func buildDetails(repo *github.Repository, commit *github.CommitsComparison, code int) *RepositoryWithDetails {
105106
return &RepositoryWithDetails{
106-
Owner: repo.GetOwner().GetLogin(),
107-
Name: repo.GetName(),
108-
FullName: repo.GetFullName(),
109-
Description: repo.GetDescription(),
110-
RepoURL: repo.GetURL(),
111-
DefaultBranch: repo.GetDefaultBranch(),
112-
Parent: repo.GetParent().GetFullName(),
113-
ParentDeleted: code == http.StatusNotFound,
114-
Private: repo.GetPrivate(),
115-
BehindBy: commit.GetBehindBy(),
107+
Owner: repo.GetOwner().GetLogin(),
108+
Name: repo.GetName(),
109+
FullName: repo.GetFullName(),
110+
Description: repo.GetDescription(),
111+
RepoURL: repo.GetURL(),
112+
DefaultBranch: repo.GetDefaultBranch(),
113+
Parent: repo.GetParent().GetOwner().GetLogin(),
114+
ParentFullName: repo.GetParent().GetFullName(),
115+
ParentDeleted: code == http.StatusNotFound,
116+
Private: repo.GetPrivate(),
117+
BehindBy: commit.GetBehindBy(),
116118
}
117119
}
118120

ui/app.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type AppModel struct {
1717

1818
func NewAppModel(client *github.Client) AppModel {
1919
list := list.New([]list.Item{}, list.NewDefaultDelegate(), 0, 0)
20+
list.Styles.Title = listTitleStyle
2021
list.Title = "Forky"
2122
list.SetSpinner(spinner.MiniDot)
2223

ui/item.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func (i item) Title() string {
1818
var fork string
1919
repo := i.repo
2020

21-
if repo.Parent != "" {
22-
fork = fmt.Sprintf(" (fork from %s)", repo.Parent)
21+
if repo.ParentFullName != "" {
22+
fork = fmt.Sprintf(" (fork from %s)", repo.ParentFullName)
2323
}
2424

2525
titleStr := repo.FullName + fork
@@ -41,7 +41,7 @@ func (i item) Title() string {
4141

4242
func (i item) Description() string {
4343
repo := i.repo
44-
upstream := fmt.Sprintf("%s:%s", repo.Parent, repo.DefaultBranch)
44+
upstream := fmt.Sprintf("%s:%s", repo.ParentFullName, repo.DefaultBranch)
4545
base := fmt.Sprintf("%s:%s", repo.FullName, repo.DefaultBranch)
4646
var msg string
4747

@@ -55,6 +55,7 @@ func (i item) Description() string {
5555
}
5656

5757
if !i.synced {
58+
upstream = fmt.Sprintf("%s:%s", repo.Parent, repo.DefaultBranch)
5859
msg = fmt.Sprintf("%s is %d commit%s behind %s", base, repo.BehindBy, mayBePlural(repo.BehindBy), upstream)
5960
}
6061

ui/styles.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ var (
77
Light: "#e94560",
88
Dark: "#f05945",
99
}
10-
listStyle = lipgloss.NewStyle().Margin(2)
10+
11+
listStyle = lipgloss.NewStyle().Margin(2)
12+
listTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("#E36CEE"))
13+
1114
detailsStyle = lipgloss.NewStyle().PaddingLeft(2)
1215

1316
errorStyle = lipgloss.NewStyle().Foreground(errorColor)

0 commit comments

Comments
 (0)