@@ -230,9 +230,10 @@ type Repository struct { | |||
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` | |||
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` | |||
Hot int64 `xorm:"-"` | |||
Active int64 `xorm:"-"` | |||
Alias string | |||
Hot int64 `xorm:"-"` | |||
Active int64 `xorm:"-"` | |||
Alias string `xorm:"INDEX"` | |||
LowerAlias string `xorm:"INDEX"` | |||
} | |||
// SanitizedOriginalURL returns a sanitized OriginalURL | |||
@@ -963,10 +964,10 @@ func isRepositoryExist(e Engine, u *User, repoName string, alias string) (bool, | |||
cond = cond.And(builder.Eq{"owner_id": u.ID}) | |||
if alias != "" { | |||
subCon := builder.NewCond() | |||
subCon = subCon.Or(builder.Eq{"alias": alias}, builder.Eq{"lower_name": repoName}) | |||
subCon = subCon.Or(builder.Eq{"lower_alias": strings.ToLower(alias)}, builder.Eq{"lower_name": strings.ToLower(repoName)}) | |||
cond = cond.And(subCon) | |||
} else { | |||
cond = cond.And(builder.Eq{"lower_name": repoName}) | |||
cond = cond.And(builder.Eq{"lower_name": strings.ToLower(repoName)}) | |||
} | |||
count, err := e.Where(cond).Count(&Repository{}) | |||
return count > 0 || com.IsDir(RepoPath(u.Name, repoName)), err | |||
@@ -985,7 +986,7 @@ func IsRepositoryAliasExist(u *User, alias string) (bool, error) { | |||
func isRepositoryAliasExist(e Engine, u *User, alias string) (bool, error) { | |||
var cond = builder.NewCond() | |||
cond = cond.And(builder.Eq{"owner_id": u.ID}) | |||
cond = cond.And(builder.Eq{"alias": alias}) | |||
cond = cond.And(builder.Eq{"lower_alias": strings.ToLower(alias)}) | |||
count, err := e.Where(cond).Count(&Repository{}) | |||
return count > 0, err | |||
} | |||
@@ -1131,6 +1132,7 @@ func IsUsableRepoAlias(name string) error { | |||
// CreateRepository creates a repository for the user/organization. | |||
func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, opts ...CreateRepoOptions) (err error) { | |||
repo.LowerAlias = strings.ToLower(repo.Alias) | |||
if err = IsUsableRepoName(repo.Name); err != nil { | |||
return err | |||
} | |||
@@ -154,6 +154,22 @@ func (a *actionNotifier) NotifyRenameRepository(doer *models.User, repo *models. | |||
} | |||
} | |||
func (a *actionNotifier) NotifyAliasRepository(doer *models.User, repo *models.Repository, oldAlias string) { | |||
log.Trace("action.ChangeRepositoryAlias: %s/%s", doer.Name, repo.Alias) | |||
if err := models.NotifyWatchers(&models.Action{ | |||
ActUserID: doer.ID, | |||
ActUser: doer, | |||
OpType: models.ActionRenameRepo, | |||
RepoID: repo.ID, | |||
Repo: repo, | |||
IsPrivate: repo.IsPrivate, | |||
Content: oldAlias, | |||
}); err != nil { | |||
log.Error("NotifyWatchers: %v", err) | |||
} | |||
} | |||
func (a *actionNotifier) NotifyTransferRepository(doer *models.User, repo *models.Repository, oldOwnerName string) { | |||
if err := models.NotifyWatchers(&models.Action{ | |||
ActUserID: doer.ID, | |||
@@ -18,6 +18,7 @@ type Notifier interface { | |||
NotifyDeleteRepository(doer *models.User, repo *models.Repository) | |||
NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) | |||
NotifyRenameRepository(doer *models.User, repo *models.Repository, oldRepoName string) | |||
NotifyAliasRepository(doer *models.User, repo *models.Repository, oldAlias string) | |||
NotifyTransferRepository(doer *models.User, repo *models.Repository, oldOwnerName string) | |||
NotifyNewIssue(*models.Issue) | |||
@@ -135,6 +135,10 @@ func (*NullNotifier) NotifyDeleteRef(doer *models.User, repo *models.Repository, | |||
func (*NullNotifier) NotifyRenameRepository(doer *models.User, repo *models.Repository, oldRepoName string) { | |||
} | |||
func (a *NullNotifier) NotifyAliasRepository(doer *models.User, repo *models.Repository, oldAlias string) { | |||
} | |||
// NotifyTransferRepository places a place holder function | |||
func (*NullNotifier) NotifyTransferRepository(doer *models.User, repo *models.Repository, oldOwnerName string) { | |||
} | |||
@@ -6,6 +6,7 @@ | |||
package repo | |||
import ( | |||
"code.gitea.io/gitea/modules/notification" | |||
"errors" | |||
"fmt" | |||
"io/ioutil" | |||
@@ -71,8 +72,10 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
} | |||
newAlias := form.Alias | |||
var aliasChanged = false | |||
// Check if repository alias has been changed. | |||
if repo.Alias != newAlias { | |||
if strings.ToLower(repo.Alias) != strings.ToLower(newAlias) { | |||
aliasChanged = true | |||
//check new alias is available or not | |||
if err := models.IsRepositoryAliasAvailable(ctx.Repo.Owner, newAlias); err != nil { | |||
ctx.Data["Err_Alias"] = true | |||
@@ -117,6 +120,10 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
log.Trace("Repository name changed: %s/%s -> %s", ctx.Repo.Owner.Name, repo.Name, newRepoName) | |||
} | |||
//notify | |||
if aliasChanged { | |||
notification.NotifyRenameRepository(ctx.Repo.Owner, repo, repo.Alias) | |||
} | |||
// In case it's just a case change. | |||
repo.Name = newRepoName | |||
@@ -125,6 +132,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
repo.Website = form.Website | |||
repo.IsTemplate = form.Template | |||
repo.Alias = newAlias | |||
repo.LowerAlias = strings.ToLower(newAlias) | |||
// Visibility of forked repository is forced sync with base repository. | |||
if repo.IsFork { | |||
@@ -404,7 +412,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
ctx.Error(404) | |||
return | |||
} | |||
if repo.Name != form.RepoName { | |||
if repo.Alias != form.RepoName { | |||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) | |||
return | |||
} | |||
@@ -431,7 +439,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
ctx.Error(404) | |||
return | |||
} | |||
if repo.Name != form.RepoName { | |||
if repo.Alias != form.RepoName { | |||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) | |||
return | |||
} | |||
@@ -469,7 +477,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
ctx.Error(404) | |||
return | |||
} | |||
if repo.Name != form.RepoName { | |||
if repo.Alias != form.RepoName { | |||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) | |||
return | |||
} | |||
@@ -489,7 +497,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { | |||
ctx.Error(404) | |||
return | |||
} | |||
if repo.Name != form.RepoName { | |||
if repo.Alias != form.RepoName { | |||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_repo_name"), tplSettingsOptions, nil) | |||
return | |||
} | |||
@@ -55,7 +55,7 @@ func TransferOwnership(doer, newOwner *models.User, repo *models.Repository, tea | |||
// ChangeRepositoryName changes all corresponding setting from old repository name to new one. | |||
func ChangeRepositoryName(doer *models.User, repo *models.Repository, newRepoName string) error { | |||
oldRepoName := repo.Name | |||
//oldRepoName := repo.Name | |||
// Change repository directory name. We must lock the local copy of the | |||
// repo so that we can atomically rename the repo path and updates the | |||
@@ -68,7 +68,7 @@ func ChangeRepositoryName(doer *models.User, repo *models.Repository, newRepoNam | |||
} | |||
repoWorkingPool.CheckOut(com.ToStr(repo.ID)) | |||
notification.NotifyRenameRepository(doer, repo, oldRepoName) | |||
//notification.NotifyRenameRepository(doer, repo, oldRepoName) | |||
return nil | |||
} |
@@ -256,11 +256,8 @@ | |||
</div> | |||
<div class="ui six wide tablet four wide computer column"> | |||
<div id="repo-desc"> | |||
<h4 id="about-desc" class="ui header">简介 | |||
<!-- <a class="edit-icon" href="javascript:void(0)"> | |||
<i class="gray edit outline icon"></i> | |||
</a> --> | |||
</h4> | |||
<h4 id="about-desc" class="ui header">简介</h4> | |||
<input type="hidden" id="edit-alias" value="{{.Repository.Alias}}"> | |||
<p> | |||
{{if .Repository.DescriptionHTML}} | |||
<span class="description" style="word-break:break-all">{{.Repository.DescriptionHTML}}</span> | |||
@@ -286,14 +283,8 @@ | |||
<i class="grey bookmark icon"></i> | |||
<div id="repo-topics1" style="flex: 1;"> | |||
<!-- {{if not .Topics}} | |||
<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span> | |||
{{end}} --> | |||
{{range .Topics}} | |||
<a class="ui repo-topic small label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.Name}}</a> | |||
{{end}} | |||
</div> | |||
<div> | |||
@@ -509,7 +509,7 @@ | |||
<div class="field"> | |||
<label> | |||
{{.i18n.Tr "repo.settings.transfer_form_title"}} | |||
<span class="text red">{{.Repository.Name}}</span> | |||
<span class="text red">{{.Repository.Alias}}</span> | |||
</label> | |||
</div> | |||
<div class="required field"> | |||
@@ -541,7 +541,7 @@ | |||
<div class="field"> | |||
<label> | |||
{{.i18n.Tr "repo.settings.transfer_form_title"}} | |||
<span class="text red">{{.Repository.Name}}</span> | |||
<span class="text red">{{.Repository.Alias}}</span> | |||
</label> | |||
</div> | |||
<div class="required field"> | |||
@@ -568,7 +568,7 @@ | |||
<div class="content"> | |||
<div class="ui warning message text left"> | |||
{{.i18n.Tr "repo.settings.delete_notices_1" | Safe}}<br> | |||
{{.i18n.Tr "repo.settings.delete_notices_2" .Repository.FullName | Safe}} | |||
{{.i18n.Tr "repo.settings.delete_notices_2" .Repository.Alias | Safe}} | |||
{{if .Repository.NumForks}}<br> | |||
{{.i18n.Tr "repo.settings.delete_notices_fork_1"}} | |||
{{end}} | |||
@@ -579,7 +579,7 @@ | |||
<div class="field"> | |||
<label> | |||
{{.i18n.Tr "repo.settings.transfer_form_title"}} | |||
<span class="text red">{{.Repository.Name}}</span> | |||
<span class="text red">{{.Repository.Alias}}</span> | |||
</label> | |||
</div> | |||
<div class="required field"> | |||
@@ -603,7 +603,7 @@ | |||
<div class="content"> | |||
<div class="ui warning message text left"> | |||
{{.i18n.Tr "repo.settings.delete_notices_1" | Safe}}<br> | |||
{{.i18n.Tr "repo.settings.wiki_delete_notices_1" .Repository.Name | Safe}} | |||
{{.i18n.Tr "repo.settings.wiki_delete_notices_1" .Repository.Alias | Safe}} | |||
</div> | |||
<form class="ui form" action="{{.Link}}" method="post"> | |||
{{.CsrfTokenHtml}} | |||
@@ -611,7 +611,7 @@ | |||
<div class="field"> | |||
<label> | |||
{{.i18n.Tr "repo.settings.transfer_form_title"}} | |||
<span class="text red">{{.Repository.Name}}</span> | |||
<span class="text red">{{.Repository.Alias}}</span> | |||
</label> | |||
</div> | |||
<div class="required field"> | |||
@@ -21,55 +21,55 @@ | |||
{{$.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}} | |||
{{$.i18n.Tr "action.create_issue" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 7}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.create_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.create_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 8}} | |||
{{$.i18n.Tr "action.transfer_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.transfer_repo" .GetContent .GetRepoLink .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 9}} | |||
{{ $branchLink := .GetBranch | EscapePound | Escape}} | |||
{{$.i18n.Tr "action.push_tag" .GetRepoLink $branchLink .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.push_tag" .GetRepoLink $branchLink .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 10}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 11}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.merge_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.merge_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 12}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.close_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.close_issue" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 13}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.reopen_issue" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.reopen_issue" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 14}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.close_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.close_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 15}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.reopen_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.reopen_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 16}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.delete_tag" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.delete_tag" .GetRepoLink .GetBranch .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 17}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.delete_branch" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.delete_branch" .GetRepoLink .GetBranch .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 18}} | |||
{{ $branchLink := .GetBranch | EscapePound}} | |||
{{$.i18n.Tr "action.mirror_sync_push" .GetRepoLink $branchLink .GetBranch .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.mirror_sync_push" .GetRepoLink $branchLink .GetBranch .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 19}} | |||
{{$.i18n.Tr "action.mirror_sync_create" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.mirror_sync_create" .GetRepoLink .GetBranch .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 20}} | |||
{{$.i18n.Tr "action.mirror_sync_delete" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.mirror_sync_delete" .GetRepoLink .GetBranch .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 21}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.approve_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.approve_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 22}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{else if eq .GetOpType 23}} | |||
{{ $index := index .GetIssueInfos 0}} | |||
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoPath | Str2html}} | |||
{{$.i18n.Tr "action.comment_pull" .GetRepoLink $index .ShortRepoFullDisplayName | Str2html}} | |||
{{end}} | |||
</p> | |||
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}} | |||
@@ -52,6 +52,7 @@ export default { | |||
desc: '', | |||
index_web: '', | |||
repo_name_name: '', | |||
alias:'' | |||
}, | |||
// rule1:[{min:3,max:5,message:'1',trigger:"blur"}], | |||
rule: { | |||
@@ -76,6 +77,7 @@ export default { | |||
getRepoName() { | |||
const el = this.url.split('/')[2]; | |||
this.info.repo_name = el; | |||
this.info.alias = $('input#edit-alias').val() | |||
}, | |||
initForm(diaolog) { | |||
if (diaolog === false) { | |||
@@ -95,6 +97,7 @@ export default { | |||
data: this.qs.stringify({ | |||
_csrf: csrf, | |||
action: 'update', | |||
alias:this.info.alias, | |||
repo_name: this.info.repo_name, | |||
description: this.info.desc, | |||
website: this.info.index_web | |||