@@ -164,12 +164,24 @@ func (a *Action) GetRepoName() string { | |||
return a.Repo.Name | |||
} | |||
// GetRepoName returns the name of the action repository. | |||
func (a *Action) GetRepoDisplayName() string { | |||
a.loadRepo() | |||
return a.Repo.DisplayName() | |||
} | |||
// ShortRepoName returns the name of the action repository | |||
// trimmed to max 33 chars. | |||
func (a *Action) ShortRepoName() string { | |||
return base.EllipsisString(a.GetRepoName(), 33) | |||
} | |||
// ShortRepoName returns the name of the action repository | |||
// trimmed to max 33 chars. | |||
func (a *Action) ShortRepoDisplayName() string { | |||
return base.EllipsisString(a.GetRepoDisplayName(), 33) | |||
} | |||
// GetRepoPath returns the virtual path to the action repository. | |||
func (a *Action) GetRepoPath() string { | |||
return path.Join(a.GetRepoUserName(), a.GetRepoName()) | |||
@@ -181,6 +193,12 @@ func (a *Action) ShortRepoPath() string { | |||
return path.Join(a.ShortRepoUserName(), a.ShortRepoName()) | |||
} | |||
// ShortRepoPath returns the virtual path to the action repository | |||
// trimmed to max 20 + 1 + 33 chars. | |||
func (a *Action) ShortRepoFullDisplayName() string { | |||
return path.Join(a.ShortRepoUserName(), a.ShortRepoDisplayName()) | |||
} | |||
// GetRepoLink returns relative link to action repository. | |||
func (a *Action) GetRepoLink() string { | |||
if len(setting.AppSubURL) > 0 { | |||
@@ -222,6 +222,7 @@ type Repository struct { | |||
Hot int64 `xorm:"-"` | |||
Active int64 `xorm:"-"` | |||
Alias string | |||
} | |||
// SanitizedOriginalURL returns a sanitized OriginalURL | |||
@@ -232,6 +233,14 @@ func (repo *Repository) SanitizedOriginalURL() string { | |||
return util.SanitizeURLCredentials(repo.OriginalURL, false) | |||
} | |||
// GetAlias returns a sanitized OriginalURL | |||
func (repo *Repository) DisplayName() string { | |||
if repo.Alias == "" { | |||
return repo.Name | |||
} | |||
return repo.Alias | |||
} | |||
// ColorFormat returns a colored string to represent this repo | |||
func (repo *Repository) ColorFormat(s fmt.State) { | |||
var ownerName interface{} | |||
@@ -285,6 +294,11 @@ func (repo *Repository) FullName() string { | |||
return repo.OwnerName + "/" + repo.Name | |||
} | |||
// FullDisplayName returns the repository full display name | |||
func (repo *Repository) FullDisplayName() string { | |||
return repo.OwnerName + "/" + repo.DisplayName() | |||
} | |||
// HTMLURL returns the repository HTML URL | |||
func (repo *Repository) HTMLURL() string { | |||
return setting.AppURL + repo.FullName() | |||
@@ -385,6 +399,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool) | |||
Owner: repo.Owner.APIFormat(), | |||
Name: repo.Name, | |||
FullName: repo.FullName(), | |||
FullDisplayName: repo.FullDisplayName(), | |||
Description: repo.Description, | |||
Private: repo.IsPrivate, | |||
Template: repo.IsTemplate, | |||
@@ -995,6 +1010,7 @@ func CheckCreateRepository(doer, u *User, name string) error { | |||
// CreateRepoOptions contains the create repository options | |||
type CreateRepoOptions struct { | |||
Name string | |||
Alias string | |||
Description string | |||
OriginalURL string | |||
GitServiceType api.GitServiceType | |||
@@ -19,6 +19,7 @@ import ( | |||
// GenerateRepoOptions contains the template units to generate | |||
type GenerateRepoOptions struct { | |||
Name string | |||
Alias string | |||
Description string | |||
Private bool | |||
GitContent bool | |||
@@ -29,6 +29,7 @@ import ( | |||
type CreateRepoForm struct { | |||
UID int64 `binding:"Required"` | |||
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"` | |||
Alias string `binding:"Required;MaxSize(100)"` | |||
Private bool | |||
Description string `binding:"MaxSize(1024)"` | |||
DefaultBranch string `binding:"GitRefName;MaxSize(100)"` | |||
@@ -28,6 +28,7 @@ func CreateRepository(doer, u *models.User, opts models.CreateRepoOptions) (_ *m | |||
Owner: u, | |||
OwnerName: u.Name, | |||
Name: opts.Name, | |||
Alias: opts.Alias, | |||
LowerName: strings.ToLower(opts.Name), | |||
Description: opts.Description, | |||
OriginalURL: opts.OriginalURL, | |||
@@ -236,6 +236,7 @@ func GenerateRepository(ctx models.DBContext, doer, owner *models.User, template | |||
Owner: owner, | |||
OwnerName: owner.Name, | |||
Name: opts.Name, | |||
Alias: opts.Alias, | |||
LowerName: strings.ToLower(opts.Name), | |||
Description: opts.Description, | |||
IsPrivate: opts.Private, | |||
@@ -46,31 +46,32 @@ type ExternalWiki struct { | |||
// Repository represents a repository | |||
type Repository struct { | |||
ID int64 `json:"id"` | |||
Owner *User `json:"owner"` | |||
Name string `json:"name"` | |||
FullName string `json:"full_name"` | |||
Description string `json:"description"` | |||
Empty bool `json:"empty"` | |||
Private bool `json:"private"` | |||
Fork bool `json:"fork"` | |||
Template bool `json:"template"` | |||
Parent *Repository `json:"parent"` | |||
Mirror bool `json:"mirror"` | |||
Size int `json:"size"` | |||
HTMLURL string `json:"html_url"` | |||
SSHURL string `json:"ssh_url"` | |||
CloneURL string `json:"clone_url"` | |||
OriginalURL string `json:"original_url"` | |||
Website string `json:"website"` | |||
Stars int `json:"stars_count"` | |||
Forks int `json:"forks_count"` | |||
Watchers int `json:"watchers_count"` | |||
OpenIssues int `json:"open_issues_count"` | |||
OpenPulls int `json:"open_pr_counter"` | |||
Releases int `json:"release_counter"` | |||
DefaultBranch string `json:"default_branch"` | |||
Archived bool `json:"archived"` | |||
ID int64 `json:"id"` | |||
Owner *User `json:"owner"` | |||
Name string `json:"name"` | |||
FullName string `json:"full_name"` | |||
FullDisplayName string `json:"full_display_name"` | |||
Description string `json:"description"` | |||
Empty bool `json:"empty"` | |||
Private bool `json:"private"` | |||
Fork bool `json:"fork"` | |||
Template bool `json:"template"` | |||
Parent *Repository `json:"parent"` | |||
Mirror bool `json:"mirror"` | |||
Size int `json:"size"` | |||
HTMLURL string `json:"html_url"` | |||
SSHURL string `json:"ssh_url"` | |||
CloneURL string `json:"clone_url"` | |||
OriginalURL string `json:"original_url"` | |||
Website string `json:"website"` | |||
Stars int `json:"stars_count"` | |||
Forks int `json:"forks_count"` | |||
Watchers int `json:"watchers_count"` | |||
OpenIssues int `json:"open_issues_count"` | |||
OpenPulls int `json:"open_pr_counter"` | |||
Releases int `json:"release_counter"` | |||
DefaultBranch string `json:"default_branch"` | |||
Archived bool `json:"archived"` | |||
// swagger:strfmt date-time | |||
Created time.Time `json:"created_at"` | |||
// swagger:strfmt date-time | |||
@@ -201,6 +201,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { | |||
if form.RepoTemplate > 0 { | |||
opts := models.GenerateRepoOptions{ | |||
Name: form.RepoName, | |||
Alias: form.Alias, | |||
Description: form.Description, | |||
Private: form.Private, | |||
GitContent: form.GitContent, | |||
@@ -235,6 +236,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { | |||
} else { | |||
repo, err = repo_service.CreateRepository(ctx.User, ctxUser, models.CreateRepoOptions{ | |||
Name: form.RepoName, | |||
Alias: form.Alias, | |||
Description: form.Description, | |||
Gitignores: form.Gitignores, | |||
IssueLabels: form.IssueLabels, | |||
@@ -24,7 +24,7 @@ | |||
{{end}} | |||
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a> | |||
<div class="divider"> / </div> | |||
<a href="{{$.RepoLink}}">{{.Name}}</a> | |||
<a href="{{$.RepoLink}}">{{.DisplayName}}</a> | |||
{{if .RelAvatarLink}} | |||
{{if .IsTemplate}} | |||
{{if .IsPrivate}} | |||
@@ -114,9 +114,9 @@ | |||
{{end}} | |||
</div> | |||
</div> | |||
{{end}} | |||
{{if .Permission.CanRead $.UnitTypeIssues}} | |||
@@ -152,7 +152,7 @@ | |||
{{if .Permission.CanRead $.UnitTypeCloudBrain}} | |||
<a class="{{if .PageIsCloudBrain}}active{{end}} item" href="{{.RepoLink}}/debugjob?debugListType=all"> | |||
<span> | |||
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 3h16a1 1 0 0 1 1 1v7H3V4a1 1 0 0 1 1-1zM3 13h18v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-7zm4 3v2h3v-2H7zM7 6v2h3V6H7z"/></svg> | |||
<svg class="svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 3h16a1 1 0 0 1 1 1v7H3V4a1 1 0 0 1 1-1zM3 13h18v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-7zm4 3v2h3v-2H7zM7 6v2h3V6H7z"/></svg> | |||
{{.i18n.Tr "repo.cloudbrain"}} | |||
<i class="question circle icon link cloudbrain-question" data-content={{.i18n.Tr "repo.cloudbrain_helper"}} data-position="top center" data-variation="mini"></i> | |||
</span> | |||
@@ -13,12 +13,12 @@ | |||
{{.ShortActUserName}} | |||
{{end}} | |||
{{if eq .GetOpType 1}} | |||
{{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.create_repo" .GetRepoLink .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 2}} | |||
{{$.i18n.Tr "action.rename_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.rename_repo" .GetContent .GetRepoLink .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 5}} | |||
{{ $branchLink := .GetBranch | EscapePound | Escape}} | |||
{{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink (Escape .GetBranch) .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink (Escape .GetBranch) .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 6}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.create_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
@@ -104,7 +104,7 @@ | |||
<li v-for="repo in repos" :class="{'private': repo.private}" v-show="showRepo(repo)"> | |||
<a :href="suburl + '/' + repo.full_name"> | |||
<svg :class="'svg ' + repoClass(repo)" width="16" height="16" aria-hidden="true"><use :xlink:href="'#' + repoClass(repo)" /></svg> | |||
<strong class="text truncate item-name">${repo.full_name}</strong> | |||
<strong class="text truncate item-name">${repo.full_display_name}</strong> | |||
<i v-if="repo.archived" class="archive icon archived-icon"></i> | |||
<span class="ui right text light grey"> | |||
${repo.stars_count} <span class="rear">{{svg "octicon-star" 16}}</span> | |||