From f43cc908411a62c9252eb42484e5096810272369 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 11 Jan 2016 20:41:43 +0800 Subject: #2287 Truncate repository name if too long --- modules/base/tool.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/base/tool.go') diff --git a/modules/base/tool.go b/modules/base/tool.go index 255c34ef5a..6bfd912d32 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -453,6 +453,15 @@ func Subtract(left interface{}, right interface{}) interface{} { } } +// EllipsisString returns a truncated short string, +// it appends '...' in the end of the length of string is too large. +func EllipsisString(str string, length int) string { + if len(str) < length { + return str + } + return str[:length-3] + "..." +} + // StringsToInt64s converts a slice of string to a slice of int64. func StringsToInt64s(strs []string) []int64 { ints := make([]int64, len(strs)) -- cgit v1.2.3