add description field to ListItem interface

This commit is contained in:
Jesse Duffield 2020-08-22 10:14:53 +10:00
parent 63209ef71e
commit 8da93fd762
9 changed files with 36 additions and 4 deletions

View file

@ -20,3 +20,7 @@ func (b *Branch) RefName() string {
func (b *Branch) ID() string {
return b.RefName()
}
func (b *Branch) Description() string {
return b.RefName()
}

View file

@ -21,10 +21,6 @@ func (c *Commit) ShortSha() string {
return c.Sha[:8]
}
func (c *Commit) NameWithSha() string {
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
}
func (c *Commit) RefName() string {
return c.Sha
}
@ -32,3 +28,7 @@ func (c *Commit) RefName() string {
func (c *Commit) ID() string {
return c.RefName()
}
func (c *Commit) Description() string {
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
}

View file

@ -11,3 +11,7 @@ type CommitFile struct {
func (f *CommitFile) ID() string {
return f.Name
}
func (f *CommitFile) Description() string {
return f.Name
}

View file

@ -40,3 +40,7 @@ func (f *File) Matches(f2 *File) bool {
func (f *File) ID() string {
return f.Name
}
func (f *File) Description() string {
return f.Name
}

View file

@ -14,3 +14,7 @@ func (r *Remote) RefName() string {
func (r *Remote) ID() string {
return r.RefName()
}
func (r *Remote) Description() string {
return r.RefName()
}

View file

@ -17,3 +17,7 @@ func (r *RemoteBranch) RefName() string {
func (r *RemoteBranch) ID() string {
return r.RefName()
}
func (r *RemoteBranch) Description() string {
return r.RefName()
}

View file

@ -15,3 +15,7 @@ func (s *StashEntry) RefName() string {
func (s *StashEntry) ID() string {
return s.RefName()
}
func (s *StashEntry) Description() string {
return s.RefName() + ": " + s.Name
}

View file

@ -12,3 +12,7 @@ func (t *Tag) RefName() string {
func (t *Tag) ID() string {
return t.RefName()
}
func (t *Tag) Description() string {
return "tag " + t.Name
}

View file

@ -33,7 +33,11 @@ type ListContext struct {
}
type ListItem interface {
// ID is a SHA when the item is a commit, a filename when the item is a file, 'stash@{4}' when it's a stash entry, 'my_branch' when it's a branch
ID() string
// Description is something we would show in a message e.g. '123as14: push blah' for a commit
Description() string
}
func (lc *ListContext) GetSelectedItem() ListItem {