1package common
2
3import (
4 "fmt"
5
6 "github.com/muesli/reflow/truncate"
7)
8
9// TruncateString is a convenient wrapper around truncate.TruncateString.
10func TruncateString(s string, max int) string {
11 if max < 0 {
12 max = 0
13 }
14 return truncate.StringWithTail(s, uint(max), "…")
15}
16
17// RepoURL returns the URL of the repository.
18func RepoURL(host string, port string, name string) string {
19 p := ""
20 if port != "22" {
21 p += ":" + port
22 }
23 return fmt.Sprintf("git clone ssh://%s/%s", host+p, name)
24}