Bug: Transfer repository doesn't update the count
This commit is contained in:
parent
f67c59135f
commit
cfed11f092
7 changed files with 21 additions and 13 deletions
|
@ -257,6 +257,7 @@ settings.site = Official Site
|
|||
settings.update_settings = Update Settings
|
||||
settings.transfer = Transfer Ownership
|
||||
settings.transfer_desc = Transfer this repo to another user or to an organization where you have admin rights.
|
||||
settings.new_owner_has_same_repo = New owner already has a repository with same name.
|
||||
settings.delete = Delete This Repository
|
||||
settings.delete_desc = Once you delete a repository, there is no going back. Please be certain.
|
||||
settings.update_settings_success = Repository options has been successfully updated.
|
||||
|
|
|
@ -257,6 +257,7 @@ settings.site = 官方网站
|
|||
settings.update_settings = 更新仓库设置
|
||||
settings.transfer = 转移仓库所有权
|
||||
settings.transfer_desc = 您可以将仓库转移至您拥有管理员权限的帐户或组织。
|
||||
settings.new_owner_has_same_repo = 新的仓库拥有者已经存在同名仓库!
|
||||
settings.delete = 删除本仓库
|
||||
settings.delete_desc = 删除仓库操作不可逆转,请三思而后行。
|
||||
settings.update_settings_success = 仓库设置更新成功!
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.5.0.0910 Beta"
|
||||
const APP_VER = "0.5.0.0912 Beta"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -644,12 +644,20 @@ func RepoPath(userName, repoName string) string {
|
|||
}
|
||||
|
||||
// TransferOwnership transfers all corresponding setting from old user to new one.
|
||||
func TransferOwnership(u *User, newOwner string, repo *Repository) (err error) {
|
||||
func TransferOwnership(u *User, newOwner string, repo *Repository) error {
|
||||
newUser, err := GetUserByName(newOwner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if new owner has repository with same name.
|
||||
has, err := IsRepositoryExist(u, repo.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if has {
|
||||
return ErrRepoAlreadyExist
|
||||
}
|
||||
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err = sess.Begin(); err != nil {
|
||||
|
@ -717,12 +725,6 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if _, err = sess.Exec(
|
||||
"UPDATE `user` SET num_repos = num_repos + 1 WHERE id = ?", u.Id); err != nil {
|
||||
sess.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
// Update owner team info and count.
|
||||
t.RepoIds += "$" + com.ToStr(repo.Id) + "|"
|
||||
t.NumRepos++
|
||||
|
@ -933,9 +935,9 @@ func GetRepositoryByRef(ref string) (*Repository, error) {
|
|||
}
|
||||
|
||||
// GetRepositoryByName returns the repository by given name under user if exists.
|
||||
func GetRepositoryByName(userId int64, repoName string) (*Repository, error) {
|
||||
func GetRepositoryByName(uid int64, repoName string) (*Repository, error) {
|
||||
repo := &Repository{
|
||||
OwnerId: userId,
|
||||
OwnerId: uid,
|
||||
LowerName: strings.ToLower(repoName),
|
||||
}
|
||||
has, err := x.Get(repo)
|
||||
|
|
|
@ -113,7 +113,11 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
|
|||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), SETTINGS_OPTIONS, nil)
|
||||
return
|
||||
} else if err = models.TransferOwnership(ctx.Repo.Owner, newOwner, ctx.Repo.Repository); err != nil {
|
||||
ctx.Handle(500, "TransferOwnership", err)
|
||||
if err == models.ErrRepoAlreadyExist {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.settings.new_owner_has_same_repo"), SETTINGS_OPTIONS, nil)
|
||||
} else {
|
||||
ctx.Handle(500, "TransferOwnership", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Trace("Repository transfered: %s/%s -> %s", ctx.Repo.Owner.Name, ctx.Repo.Repository.Name, newOwner)
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.5.0.0910 Beta
|
||||
0.5.0.0912 Beta
|
|
@ -14,7 +14,7 @@
|
|||
</p>
|
||||
<div class="{{if .ReadmeExist}}panel-content markdown{{end}} code-view">
|
||||
{{if .ReadmeExist}}
|
||||
{{.FileContent | Str2html}}
|
||||
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
|
||||
{{else if not .IsFileText}}
|
||||
<div class="view-raw">
|
||||
{{if .IsImageFile}}
|
||||
|
|
Loading…
Reference in a new issue