Bug: 500 when transfer repository to collaborator
This commit is contained in:
parent
ce6931a046
commit
3cfa4a581c
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.5.4.0928 Beta"
|
const APP_VER = "0.5.4.0929 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -678,17 +678,25 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
|
||||||
return fmt.Errorf("fail to delete current accesses: %v", err)
|
return fmt.Errorf("fail to delete current accesses: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Delete current owner access.
|
||||||
if _, err = sess.Where("repo_name=?", oldRepoLink).And("user_name=?", owner.LowerName).
|
if _, err = sess.Where("repo_name=?", oldRepoLink).And("user_name=?", owner.LowerName).
|
||||||
Update(&Access{UserName: newUser.LowerName}); err != nil {
|
Delete(new(Access)); err != nil {
|
||||||
sess.Rollback()
|
sess.Rollback()
|
||||||
return err
|
return fmt.Errorf("fail to delete access(owner): %v", err)
|
||||||
|
}
|
||||||
|
// In case new owner has access.
|
||||||
|
if _, err = sess.Where("repo_name=?", oldRepoLink).And("user_name=?", newUser.LowerName).
|
||||||
|
Delete(new(Access)); err != nil {
|
||||||
|
sess.Rollback()
|
||||||
|
return fmt.Errorf("fail to delete access(new user): %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change accesses to new repository path.
|
||||||
if _, err = sess.Where("repo_name=?", oldRepoLink).
|
if _, err = sess.Where("repo_name=?", oldRepoLink).
|
||||||
Update(&Access{RepoName: path.Join(newUser.LowerName, repo.LowerName)}); err != nil {
|
Update(&Access{RepoName: path.Join(newUser.LowerName, repo.LowerName)}); err != nil {
|
||||||
sess.Rollback()
|
sess.Rollback()
|
||||||
return err
|
return fmt.Errorf("fail to update access(change reponame): %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update repository.
|
// Update repository.
|
||||||
|
@ -754,7 +762,7 @@ func TransferOwnership(u *User, newOwner string, repo *Repository) error {
|
||||||
}
|
}
|
||||||
if _, err = sess.Insert(access); err != nil {
|
if _, err = sess.Insert(access); err != nil {
|
||||||
sess.Rollback()
|
sess.Rollback()
|
||||||
return err
|
return fmt.Errorf("fail to insert access: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.5.4.0928 Beta
|
0.5.4.0929 Beta
|
|
@ -20,9 +20,11 @@
|
||||||
<!-- <li>
|
<!-- <li>
|
||||||
<a class="radius" href="#"><i class="octicon octicon-organization"></i>contributors <span class="num right label label-gray label-radius">43</span></a>
|
<a class="radius" href="#"><i class="octicon octicon-organization"></i>contributors <span class="num right label label-gray label-radius">43</span></a>
|
||||||
</li> -->
|
</li> -->
|
||||||
|
{{if .IsRepositoryTrueOwner}}
|
||||||
<li class="border-bottom"></li>
|
<li class="border-bottom"></li>
|
||||||
<li>
|
<li>
|
||||||
<a class="radius" href="{{.RepoLink}}/settings"><i class="octicon octicon-tools"></i>{{.i18n.Tr "repo.settings"}}</a>
|
<a class="radius" href="{{.RepoLink}}/settings"><i class="octicon octicon-tools"></i>{{.i18n.Tr "repo.settings"}}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue