]> source.dussan.org Git - gitea.git/commitdiff
Fix bug on transfer repo
authorUnknwon <joe2010xtmf@163.com>
Thu, 25 Sep 2014 20:36:19 +0000 (16:36 -0400)
committerUnknwon <joe2010xtmf@163.com>
Thu, 25 Sep 2014 20:36:19 +0000 (16:36 -0400)
.gitignore
cmd/web.go
conf/locale/locale_en-US.ini
conf/locale/locale_zh-CN.ini
gogs.go
models/action.go
models/repo.go
modules/base/template.go
templates/.VERSION
templates/user/dashboard/dashboard.tmpl

index 57d1493b06d4b9729c368fa164c2bfbf69bfa57e..3f7608d7ec4226100ae592f1963b9d9995965b6d 100644 (file)
@@ -39,3 +39,6 @@ __pycache__
 output*
 config.codekit
 .brackets.json
+docker/fig.yml
+docker/docker/Dockerfile
+docker/docker/init_gogs.sh
index 2376fd2126de0ba88a07aa989f34c8c25cf91ae0..8a87f86bb1edeffc951b2e5204efc79318b1e123 100644 (file)
@@ -190,7 +190,8 @@ func runWeb(*cli.Context) {
                r.Get("/logout", user.SignOut)
        })
 
-       m.Get("/user/:username", ignSignIn, user.Profile) // TODO: Legacy
+       // FIXME: Legacy
+       m.Get("/user/:username", ignSignIn, user.Profile)
 
        // Gravatar service.
        avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg")
index 15d8028c4ffd97b6b8ac457c3cbbfa098b8f33f4..13be2fbd00e87cfa43afedc93a6dcbf95d5cf48b 100644 (file)
@@ -565,6 +565,7 @@ create_repo = created repository <a href="%s/%s">%s</a>
 commit_repo = pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a>
 create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a>
 comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a>
+transfer_repo = transfered repository <code>%s</code> to <a href="%s%s">%s</a>
 
 [tool]
 ago = ago
index e479f5cdf73fb8a384a68f1a146c3f1cf772a4ee..7d65abd30b716c693610153163e975d725b8abfa 100644 (file)
@@ -563,6 +563,7 @@ create_repo = 创建了仓库 <a href="%s/%s">%s</a>
 commit_repo = 推送了 <a href="%s/%s/src/%s">%s</a> 分支的代码到 <a href="%s/%s">%s</a>
 create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a>
 comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a>
+transfer_repo = 将仓库 <code>%s</code> 转移至 <a href="%s%s">%s</a>
 
 [tool]
 ago = 之前
diff --git a/gogs.go b/gogs.go
index 6956b9f50a01c9ba9999007d975cd20f5ae5b4f9..2f5b24176e089a70ac2aed3731e664eca7491397 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.5.4.0924 Beta"
+const APP_VER = "0.5.4.0925 Beta"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index 18c956bda12fe6b8c0ba654b27d4caebda92dffb..46500a926056a7694c12ae5782f1a9d06520cd5e 100644 (file)
@@ -351,8 +351,8 @@ func NewRepoAction(u *User, repo *Repository) (err error) {
 // TransferRepoAction adds new action for transfering repository.
 func TransferRepoAction(u, newUser *User, repo *Repository) (err error) {
        if err = NotifyWatchers(&Action{ActUserId: u.Id, ActUserName: u.Name, ActEmail: u.Email,
-               OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: repo.Owner.Name,
-               RepoName: repo.Name, Content: newUser.Name,
+               OpType: TRANSFER_REPO, RepoId: repo.Id, RepoUserName: newUser.Name,
+               RepoName:  repo.Name,
                IsPrivate: repo.IsPrivate}); err != nil {
                log.Error(4, "NotifyWatchers: %d/%s", u.Id, repo.Name)
                return err
index c0a581b9a25b2d66ba96fd3d483ffafefcf3cdb1..093e3b7f577710ed8d64cc68f39bdfcb4a8baa1f 100644 (file)
@@ -669,15 +669,23 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
                return err
        }
 
-       if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName).
-               And("user_name = ?", u.LowerName).Update(&Access{UserName: newUser.LowerName}); err != nil {
-               sess.Rollback()
-               return err
+       curRepoLink := path.Join(u.LowerName, repo.LowerName)
+       // Delete all access first if current owner is an organization.
+       if u.IsOrganization() {
+               if _, err = sess.Where("repo_name=?", curRepoLink).Delete(new(Access)); err != nil {
+                       sess.Rollback()
+                       return fmt.Errorf("fail to delete current accesses: %v", err)
+               }
+       } else {
+               if _, err = sess.Where("repo_name=?", curRepoLink).And("user_name=?", u.LowerName).
+                       Update(&Access{UserName: newUser.LowerName}); err != nil {
+                       sess.Rollback()
+                       return err
+               }
        }
 
-       if _, err = sess.Where("repo_name = ?", u.LowerName+"/"+repo.LowerName).Update(&Access{
-               RepoName: newUser.LowerName + "/" + repo.LowerName,
-       }); err != nil {
+       if _, err = sess.Where("repo_name=?", curRepoLink).
+               Update(&Access{RepoName: path.Join(newUser.LowerName, repo.LowerName)}); err != nil {
                sess.Rollback()
                return err
        }
@@ -700,12 +708,12 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
                return err
        }
 
+       mode := WRITABLE
+       if repo.IsMirror {
+               mode = READABLE
+       }
        // New owner is organization.
        if newUser.IsOrganization() {
-               mode := WRITABLE
-               if repo.IsMirror {
-                       mode = READABLE
-               }
                access := &Access{
                        RepoName: path.Join(newUser.LowerName, repo.LowerName),
                        Mode:     mode,
@@ -737,6 +745,16 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
                        sess.Rollback()
                        return err
                }
+       } else {
+               access := &Access{
+                       RepoName: path.Join(newUser.LowerName, repo.LowerName),
+                       UserName: newUser.LowerName,
+                       Mode:     mode,
+               }
+               if _, err = sess.Insert(access); err != nil {
+                       sess.Rollback()
+                       return err
+               }
        }
 
        // Change repository directory name.
index ec41914937fdddaee4131d0e6e7e2922627f9c5e..b1c8c161d34a9e0add53b7528b9cfc1e7a3e1abc 100644 (file)
@@ -149,14 +149,12 @@ type Actioner interface {
 // and returns a icon class name.
 func ActionIcon(opType int) string {
        switch opType {
-       case 1: // Create repository.
+       case 1, 8: // Create, transfer repository.
                return "repo"
        case 5, 9: // Commit repository.
                return "git-commit"
        case 6: // Create issue.
                return "issue-opened"
-       case 8: // Transfer repository.
-               return "share"
        case 10: // Comment issue.
                return "comment"
        default:
@@ -164,7 +162,7 @@ func ActionIcon(opType int) string {
        }
 }
 
-// TODO: Legacy
+// FIXME: Legacy
 const (
        TPL_CREATE_REPO    = `<a href="%s/user/%s">%s</a> created repository <a href="%s">%s</a>`
        TPL_COMMIT_REPO    = `<a href="%s/user/%s">%s</a> pushed to <a href="%s/src/%s">%s</a> at <a href="%s">%s</a>%s`
@@ -197,7 +195,7 @@ func ActionContent2Commits(act Actioner) *PushCommits {
        return push
 }
 
-// TODO: Legacy
+// FIXME: Legacy
 // ActionDesc accepts int that represents action operation type
 // and returns the description.
 func ActionDesc(act Actioner) string {
index 49d86b406c1c6b07156b65dc1618ea7aecd935e9..87b06b81620dbe90497467596826dde638c84157 100644 (file)
@@ -1 +1 @@
-0.5.4.0924 Beta
\ No newline at end of file
+0.5.4.0925 Beta
\ No newline at end of file
index 0d728ef451c78419a69bab852a6defb2820506fd..370173e4739b83d1d93cee1a0a526b36cffbbe99 100644 (file)
@@ -20,6 +20,8 @@
                         {{else if eq .GetOpType 6}}
                         {{ $index := index .GetIssueInfos 0}}
                         {{$.i18n.Tr "action.create_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}}
+                        {{else if eq .GetOpType 8}}
+                        {{$.i18n.Tr "action.transfer_repo" .GetRepoName AppSubUrl .GetRepoLink .GetRepoLink | Str2html}}
                         {{else if eq .GetOpType 10}}
                         {{ $index := index .GetIssueInfos 0}}
                         {{$.i18n.Tr "action.comment_issue" AppSubUrl .GetRepoLink $index .GetRepoLink $index | Str2html}}