From 1b66600bd0e9eaa52f2f14f58c9cdf504efadaf5 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 23 Nov 2014 02:33:47 -0500 Subject: Fix #652 --- models/publickey.go | 5 +++++ models/repo.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'models') diff --git a/models/publickey.go b/models/publickey.go index 29c12c6e..ba15ca45 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -89,6 +89,11 @@ type PublicKey struct { HasUsed bool `xorm:"-"` } +// OmitEmail returns content of public key but without e-mail address. +func (k *PublicKey) OmitEmail() string { + return strings.Join(strings.Split(k.Content, " ")[:2], " ") +} + // GetAuthorizedString generates and returns formatted public key string for authorized_keys file. func (key *PublicKey) GetAuthorizedString() string { return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, key.Id, key.Content) diff --git a/models/repo.go b/models/repo.go index 937bd8c1..e4f47068 100644 --- a/models/repo.go +++ b/models/repo.go @@ -243,7 +243,7 @@ func IsRepositoryExist(u *User, repoName string) (bool, error) { var ( illegalEquals = []string{"debug", "raw", "install", "api", "avatar", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "new"} - illegalSuffixs = []string{".git"} + illegalSuffixs = []string{".git", ".keys"} ) // IsLegalName returns false if name contains illegal characters. -- cgit v1.2.3