diff options
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go index 6069be1243..936ad2ae37 100644 --- a/models/repo.go +++ b/models/repo.go @@ -18,6 +18,7 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" "time" @@ -210,6 +211,24 @@ type Repository struct { UpdatedUnix util.TimeStamp `xorm:"INDEX updated"` } +// ColorFormat returns a colored string to represent this repo +func (repo *Repository) ColorFormat(s fmt.State) { + var ownerName interface{} + + if repo.OwnerName != "" { + ownerName = repo.OwnerName + } else if repo.Owner != nil { + ownerName = repo.Owner.Name + } else { + ownerName = log.NewColoredIDValue(strconv.FormatInt(repo.OwnerID, 10)) + } + + log.ColorFprintf(s, "%d:%s/%s", + log.NewColoredIDValue(repo.ID), + ownerName, + repo.Name) +} + // AfterLoad is invoked from XORM after setting the values of all fields of this object. func (repo *Repository) AfterLoad() { // FIXME: use models migration to solve all at once. |