1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-14 22:47:21 +00:00

General code quality improvement

This commit is contained in:
Unknwon
2016-08-16 23:06:38 -07:00
parent 6f9a95f830
commit a00c932bbc
17 changed files with 180 additions and 171 deletions

View File

@ -393,12 +393,12 @@ func (repo *Repository) GitConfigPath() string {
return filepath.Join(repo.RepoPath(), "config")
}
func (repo *Repository) Link() string {
return setting.AppSubUrl + "/" + repo.MustOwner().Name + "/" + repo.Name
func (repo *Repository) RelLink() string {
return "/" + repo.FullName()
}
func (repo *Repository) RelLink() string {
return "/" + repo.MustOwner().Name + "/" + repo.Name
func (repo *Repository) Link() string {
return setting.AppSubUrl + "/" + repo.FullName()
}
func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
@ -1167,7 +1167,7 @@ func RepoPath(userName, repoName string) string {
}
// TransferOwnership transfers all corresponding setting from old user to new one.
func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error {
newOwner, err := GetUserByName(newOwnerName)
if err != nil {
return fmt.Errorf("get new owner '%s': %v", newOwnerName, err)
@ -1190,7 +1190,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
owner := repo.Owner
// Note: we have to set value here to make sure recalculate accesses is based on
// new owner.
// new owner.
repo.OwnerID = newOwner.ID
repo.Owner = newOwner
@ -1260,7 +1260,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
if err = watchRepo(sess, newOwner.ID, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err)
} else if err = transferRepoAction(sess, u, owner, newOwner, repo); err != nil {
} else if err = transferRepoAction(sess, doer, owner, repo); err != nil {
return fmt.Errorf("transferRepoAction: %v", err)
}
@ -1530,16 +1530,16 @@ func GetRepositoryByRef(ref string) (*Repository, error) {
}
// GetRepositoryByName returns the repository by given name under user if exists.
func GetRepositoryByName(uid int64, repoName string) (*Repository, error) {
func GetRepositoryByName(ownerID int64, name string) (*Repository, error) {
repo := &Repository{
OwnerID: uid,
LowerName: strings.ToLower(repoName),
OwnerID: ownerID,
LowerName: strings.ToLower(name),
}
has, err := x.Get(repo)
if err != nil {
return nil, err
} else if !has {
return nil, ErrRepoNotExist{0, uid, repoName}
return nil, ErrRepoNotExist{0, ownerID, name}
}
return repo, err
}