Detailed changes
@@ -90,7 +90,7 @@ var _ tea.Model = &model{}
func (m *model) SetSize(w, h int) {
m.common.SetSize(w, h)
- style := m.common.Styles.App.Copy()
+ style := m.common.Styles.App
wm := style.GetHorizontalFrameSize()
hm := style.GetVerticalFrameSize()
if m.showFooter {
@@ -206,7 +206,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// View implements tea.Model.
func (m *model) View() string {
- style := m.common.Styles.App.Copy()
+ style := m.common.Styles.App
wm, hm := style.GetHorizontalFrameSize(), style.GetVerticalFrameSize()
if m.showFooter {
hm += m.footer.Height()
@@ -219,7 +219,7 @@ func (m *model) View() string {
case errorState:
err := m.common.Styles.ErrorTitle.Render("Bummer")
err += m.common.Styles.ErrorBody.Render(m.error.Error())
- view = m.common.Styles.Error.Copy().
+ view = m.common.Styles.Error.
Width(m.common.Width -
wm -
m.common.Styles.ErrorBody.GetHorizontalFrameSize()).
@@ -109,7 +109,7 @@ var (
<-done
- ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
if err := s.Shutdown(ctx); err != nil {
return err
@@ -54,8 +54,10 @@ func ParseAccessLevel(s string) AccessLevel {
}
}
-var _ encoding.TextMarshaler = AccessLevel(0)
-var _ encoding.TextUnmarshaler = (*AccessLevel)(nil)
+var (
+ _ encoding.TextMarshaler = AccessLevel(0)
+ _ encoding.TextUnmarshaler = (*AccessLevel)(nil)
+)
// ErrInvalidAccessLevel is returned when an invalid access level is provided.
var ErrInvalidAccessLevel = errors.New("invalid access level")
@@ -37,11 +37,8 @@ var (
}, []string{"repo"})
)
-var (
-
- // ErrServerClosed indicates that the server has been closed.
- ErrServerClosed = fmt.Errorf("git: %w", net.ErrClosed)
-)
+// ErrServerClosed indicates that the server has been closed.
+var ErrServerClosed = fmt.Errorf("git: %w", net.ErrClosed)
// GitDaemon represents a Git daemon.
type GitDaemon struct {
@@ -52,8 +52,10 @@ func migrateDown(ctx context.Context, tx *db.Tx, version int, name string) error
return execMigration(ctx, tx, version, name, true)
}
-var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
-var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
+var (
+ matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
+ matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
+)
func toSnakeCase(str string) string {
str = strings.ReplaceAll(str, "-", "_")
@@ -14,10 +14,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/pktline"
)
-var (
- // ErrNoBranches is returned when a repo has no branches.
- ErrNoBranches = errors.New("no branches found")
-)
+// ErrNoBranches is returned when a repo has no branches.
+var ErrNoBranches = errors.New("no branches found")
// WritePktline encodes and writes a pktline to the given writer.
func WritePktline(w io.Writer, v ...interface{}) error {
@@ -177,7 +177,7 @@ func (t *lfsTransfer) Upload(oid string, size int64, r io.Reader, _ transfer.Arg
}
// Verify implements transfer.Backend.
-func (t *lfsTransfer) Verify(oid string, size int64, args transfer.Args) (transfer.Status, error) {
+func (t *lfsTransfer) Verify(oid string, size int64, _ transfer.Args) (transfer.Status, error) {
obj, err := t.store.GetLFSObjectByOid(t.ctx, t.dbx, t.repo.ID(), oid)
if err != nil {
if errors.Is(err, db.ErrRecordNotFound) {
@@ -65,7 +65,7 @@ func NewUI(c common.Common, initialRepo string) *UI {
}
func (ui *UI) getMargins() (wm, hm int) {
- style := ui.common.Styles.App.Copy()
+ style := ui.common.Styles.App
switch ui.activePage {
case selectionPage:
hm += ui.common.Styles.ServerName.GetHeight() +
@@ -271,7 +271,7 @@ func (ui *UI) View() string {
case errorState:
err := ui.common.Styles.ErrorTitle.Render("Bummer")
err += ui.common.Styles.ErrorBody.Render(ui.error.Error())
- view = ui.common.Styles.Error.Copy().
+ view = ui.common.Styles.Error.
Width(ui.common.Width -
wm -
ui.common.Styles.ErrorBody.GetHorizontalFrameSize()).
@@ -6,10 +6,8 @@ import (
"github.com/muesli/termenv"
)
-var (
- // DefaultColorProfile is the default color profile used by the SSH server.
- DefaultColorProfile = termenv.ANSI256
-)
+// DefaultColorProfile is the default color profile used by the SSH server.
+var DefaultColorProfile = termenv.ANSI256
func strptr(s string) *string {
return &s
@@ -47,7 +47,7 @@ func New(c common.Common, content, extension string) *Code {
TabWidth: defaultTabWidth,
SideNotePercent: defaultSideNotePercent,
Viewport: vp.New(c),
- NoContentStyle: c.Styles.NoContent.Copy().SetString("No Content."),
+ NoContentStyle: c.Styles.NoContent.SetString("No Content."),
}
st := common.StyleConfig()
r.styleConfig = st
@@ -56,7 +56,7 @@ func (f *Footer) View() string {
if f.keymap == nil {
return ""
}
- s := f.common.Styles.Footer.Copy().
+ s := f.common.Styles.Footer.
Width(f.common.Width)
helpView := f.help.View(f.keymap)
return f.common.Zone.Mark(
@@ -90,10 +90,10 @@ func (t *Tabs) View() string {
s := strings.Builder{}
sep := t.TabSeparator
for i, tab := range t.tabs {
- style := t.TabInactive.Copy()
+ style := t.TabInactive
prefix := " "
if i == t.activeTab {
- style = t.TabActive.Copy()
+ style = t.TabActive
prefix = t.TabDot.Render("β’ ")
}
if t.UseDot {
@@ -118,14 +118,14 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
nameStyle = s.Active.FileName
sizeStyle = s.Active.FileSize
modeStyle = s.Active.FileMode
- fmt.Fprint(w, s.Selector.Render(">"))
+ fmt.Fprint(w, s.Selector.Render(">")) //nolint:errcheck
} else {
nameStyle = s.Normal.FileName
sizeStyle = s.Normal.FileSize
modeStyle = s.Normal.FileMode
- fmt.Fprint(w, s.Selector.Render(" "))
+ fmt.Fprint(w, s.Selector.Render(" ")) //nolint:errcheck
}
- sizeStyle = sizeStyle.Copy().
+ sizeStyle = sizeStyle.
Width(8).
Align(lipgloss.Right).
MarginLeft(1)
@@ -142,6 +142,7 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
truncate := d.common.Renderer.NewStyle().MaxWidth(m.Width() -
s.Selector.GetHorizontalFrameSize() -
s.Selector.GetWidth())
+ //nolint:errcheck
fmt.Fprint(w,
d.common.Zone.Mark(
i.ID(),
@@ -346,7 +346,7 @@ func (l *Log) View() string {
msg += "s"
}
msg += "β¦"
- return l.common.Styles.SpinnerContainer.Copy().
+ return l.common.Styles.SpinnerContainer.
Height(l.common.Height).
Render(msg)
}
@@ -97,7 +97,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
// title truncation symbol (1)
9),
)
- hashStyle := styles.Hash.Copy().
+ hashStyle := styles.Hash.
Align(lipgloss.Right).
PaddingLeft(1).
Width(m.Width() -
@@ -33,7 +33,7 @@ type Readme struct {
// NewReadme creates a new readme model.
func NewReadme(common common.Common) *Readme {
readme := code.New(common, "", "")
- readme.NoContentStyle = readme.NoContentStyle.Copy().SetString("No readme found.")
+ readme.NoContentStyle = readme.NoContentStyle.SetString("No readme found.")
readme.UseGlamour = true
s := spinner.New(spinner.WithSpinner(spinner.Dot),
spinner.WithStyle(common.Styles.Spinner))
@@ -141,7 +141,7 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
t := i.Tag
if t != nil {
- msgSt := st.ItemDesc.Copy().Faint(false)
+ msgSt := st.ItemDesc.Faint(false)
msg := t.Message()
nl := strings.Index(msg, "\n")
if nl > 0 {
@@ -186,7 +186,7 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
lipgloss.Width(sha) -
1 // 1 is for the left padding
if hashMargin >= 0 {
- hash = strings.Repeat(" ", hashMargin) + st.ItemHash.Copy().
+ hash = strings.Repeat(" ", hashMargin) + st.ItemHash.
Align(lipgloss.Right).
PaddingLeft(1).
Render(sha)
@@ -295,10 +295,10 @@ func (r *Repo) View() string {
wm, hm := r.getMargins()
hm += r.common.Styles.Tabs.GetHeight() +
r.common.Styles.Tabs.GetVerticalFrameSize()
- s := r.common.Styles.Repo.Base.Copy().
+ s := r.common.Styles.Repo.Base.
Width(r.common.Width - wm).
Height(r.common.Height - hm)
- mainStyle := r.common.Styles.Repo.Body.Copy().
+ mainStyle := r.common.Styles.Repo.Body.
Height(r.common.Height - hm)
var main string
var statusbar string
@@ -339,7 +339,7 @@ func (r *Repo) headerView() string {
r.common.Styles.Repo.HeaderDesc.Render(desc),
)
}
- urlStyle := r.common.Styles.URLStyle.Copy().
+ urlStyle := r.common.Styles.URLStyle.
Width(r.common.Width - lipgloss.Width(desc) - 1).
Align(lipgloss.Right)
var url string
@@ -354,7 +354,7 @@ func (r *Repo) headerView() string {
header = lipgloss.JoinHorizontal(lipgloss.Left, header, url)
- style := r.common.Styles.Repo.Header.Copy().Width(r.common.Width)
+ style := r.common.Styles.Repo.Header.Width(r.common.Width)
return style.Render(
truncate.Render(header),
)
@@ -425,7 +425,7 @@ func switchTabCmd(m common.TabComponent) tea.Cmd {
func renderLoading(c common.Common, s spinner.Model) string {
msg := fmt.Sprintf("%s loadingβ¦", s.View())
- return c.Styles.SpinnerContainer.Copy().
+ return c.Styles.SpinnerContainer.
Height(c.Height).
Render(msg)
}
@@ -178,7 +178,7 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
if m.Width()-styles.Base.GetHorizontalFrameSize()-lipgloss.Width(updatedStr)-lipgloss.Width(title) <= 0 {
updatedStr = ""
}
- updatedStyle := styles.Updated.Copy().
+ updatedStyle := styles.Updated.
Align(lipgloss.Right).
Width(m.Width() - styles.Base.GetHorizontalFrameSize() - lipgloss.Width(title))
updated := updatedStyle.Render(updatedStr)
@@ -189,8 +189,8 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
}
if isFiltered {
- unmatched := styles.Title.Copy().Inline(true)
- matched := unmatched.Copy().Underline(true)
+ unmatched := styles.Title.Inline(true)
+ matched := unmatched.Underline(true)
title = lipgloss.StyleRunes(title, matchedRunes, matched, unmatched)
}
title = styles.Title.Render(title)
@@ -52,9 +52,9 @@ func New(c common.Common) *Selection {
}
t := tabs.New(c, ts)
t.TabSeparator = c.Renderer.NewStyle()
- t.TabInactive = c.Styles.TopLevelNormalTab.Copy()
- t.TabActive = c.Styles.TopLevelActiveTab.Copy()
- t.TabDot = c.Styles.TopLevelActiveTabDot.Copy()
+ t.TabInactive = c.Styles.TopLevelNormalTab
+ t.TabActive = c.Styles.TopLevelActiveTab
+ t.TabDot = c.Styles.TopLevelActiveTabDot
t.UseDot = true
sel := &Selection{
common: c,
@@ -63,7 +63,7 @@ func New(c common.Common) *Selection {
}
readme := code.New(c, "", "")
readme.UseGlamour = true
- readme.NoContentStyle = c.Styles.NoContent.Copy().
+ readme.NoContentStyle = c.Styles.NoContent.
SetString(defaultNoContent)
selector := selector.New(c,
[]selector.IdentifiableItem{},
@@ -191,7 +191,7 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
s.TopLevelNormalTab = r.NewStyle().
MarginRight(2)
- s.TopLevelActiveTab = s.TopLevelNormalTab.Copy().
+ s.TopLevelActiveTab = s.TopLevelNormalTab.
Foreground(lipgloss.Color("36"))
s.TopLevelActiveTabDot = r.NewStyle().
@@ -213,20 +213,20 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
s.RepoSelector.Normal.Updated = r.NewStyle().
Foreground(lipgloss.Color("243"))
- s.RepoSelector.Active.Base = s.RepoSelector.Normal.Base.Copy().
+ s.RepoSelector.Active.Base = s.RepoSelector.Normal.Base.
BorderStyle(lipgloss.Border{Left: "β"}).
BorderForeground(lipgloss.Color("176"))
- s.RepoSelector.Active.Title = s.RepoSelector.Normal.Title.Copy().
+ s.RepoSelector.Active.Title = s.RepoSelector.Normal.Title.
Foreground(lipgloss.Color("212"))
- s.RepoSelector.Active.Desc = s.RepoSelector.Normal.Desc.Copy().
+ s.RepoSelector.Active.Desc = s.RepoSelector.Normal.Desc.
Foreground(lipgloss.Color("246"))
- s.RepoSelector.Active.Updated = s.RepoSelector.Normal.Updated.Copy().
+ s.RepoSelector.Active.Updated = s.RepoSelector.Normal.Updated.
Foreground(lipgloss.Color("212"))
- s.RepoSelector.Active.Command = s.RepoSelector.Normal.Command.Copy().
+ s.RepoSelector.Active.Command = s.RepoSelector.Normal.Command.
Foreground(lipgloss.Color("204"))
s.MenuItem = r.NewStyle().
@@ -306,13 +306,13 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
}, false, false, false, true).
PaddingLeft(1)
- s.LogItem.Active.Base = s.LogItem.Normal.Base.Copy().
+ s.LogItem.Active.Base = s.LogItem.Normal.Base.
Border(lipgloss.Border{
Left: "β",
}, false, false, false, true).
BorderForeground(selectorColor)
- s.LogItem.Active.Hash = s.LogItem.Normal.Hash.Copy().
+ s.LogItem.Active.Hash = s.LogItem.Normal.Hash.
Foreground(hashColor)
s.LogItem.Active.Hash = r.NewStyle().
@@ -332,7 +332,7 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
s.LogItem.Active.Desc = r.NewStyle().
Foreground(lipgloss.Color("95"))
- s.LogItem.Active.Keyword = s.LogItem.Active.Desc.Copy().
+ s.LogItem.Active.Keyword = s.LogItem.Active.Desc.
Foreground(highlightColorDim)
s.LogItem.Normal.Hash = r.NewStyle().
@@ -403,18 +403,18 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
Foreground(highlightColor).
Bold(true)
- s.Ref.Paginator = s.Log.Paginator.Copy()
+ s.Ref.Paginator = s.Log.Paginator
s.Ref.Selector = r.NewStyle()
- s.Tree.Selector = s.Tree.Normal.FileName.Copy().
+ s.Tree.Selector = s.Tree.Normal.FileName.
Width(1).
Foreground(selectorColor)
s.Tree.Normal.FileName = r.NewStyle().
MarginLeft(1)
- s.Tree.Active.FileName = s.Tree.Normal.FileName.Copy().
+ s.Tree.Active.FileName = s.Tree.Normal.FileName.
Bold(true).
Foreground(highlightColor)
@@ -424,22 +424,22 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
s.Tree.Active.FileDir = r.NewStyle().
Foreground(highlightColor)
- s.Tree.Normal.FileMode = s.Tree.Active.FileName.Copy().
+ s.Tree.Normal.FileMode = s.Tree.Active.FileName.
Width(10).
Foreground(lipgloss.Color("243"))
- s.Tree.Active.FileMode = s.Tree.Normal.FileMode.Copy().
+ s.Tree.Active.FileMode = s.Tree.Normal.FileMode.
Foreground(highlightColorDim)
- s.Tree.Normal.FileSize = s.Tree.Normal.FileName.Copy().
+ s.Tree.Normal.FileSize = s.Tree.Normal.FileName.
Foreground(lipgloss.Color("243"))
- s.Tree.Active.FileSize = s.Tree.Normal.FileName.Copy().
+ s.Tree.Active.FileSize = s.Tree.Normal.FileName.
Foreground(highlightColorDim)
s.Tree.FileContent = r.NewStyle()
- s.Tree.Paginator = s.Log.Paginator.Copy()
+ s.Tree.Paginator = s.Log.Paginator
s.Tree.Blame.Hash = r.NewStyle().
Foreground(hashColor).
@@ -511,7 +511,7 @@ func DefaultStyles(r *lipgloss.Renderer) *Styles {
s.Stash.Normal.Message = r.NewStyle().MarginLeft(1)
- s.Stash.Active.Message = s.Stash.Normal.Message.Copy().Foreground(selectorColor)
+ s.Stash.Active.Message = s.Stash.Normal.Message.Foreground(selectorColor)
s.Stash.Title = r.NewStyle().
Foreground(hashColor).
@@ -45,8 +45,10 @@ func ParseContentType(s string) (ContentType, error) {
return -1, ErrInvalidContentType
}
-var _ encoding.TextMarshaler = ContentType(0)
-var _ encoding.TextUnmarshaler = (*ContentType)(nil)
+var (
+ _ encoding.TextMarshaler = ContentType(0)
+ _ encoding.TextUnmarshaler = (*ContentType)(nil)
+)
// UnmarshalText implements encoding.TextUnmarshaler.
func (c *ContentType) UnmarshalText(text []byte) error {
@@ -76,8 +76,10 @@ func ParseEvent(s string) (Event, error) {
return e, nil
}
-var _ encoding.TextMarshaler = Event(0)
-var _ encoding.TextUnmarshaler = (*Event)(nil)
+var (
+ _ encoding.TextMarshaler = Event(0)
+ _ encoding.TextUnmarshaler = (*Event)(nil)
+)
// UnmarshalText implements encoding.TextUnmarshaler.
func (e *Event) UnmarshalText(text []byte) error {