Skip to content

Fix renames over redirects #6216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,11 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
}
}

// If there was previously a redirect at this location, remove it.
if err = deleteRepoRedirect(sess, newOwner.ID, repo.Name); err != nil {
return fmt.Errorf("delete repo redirect: %v", err)
}

return sess.Commit()
}

Expand Down Expand Up @@ -1614,7 +1619,18 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
}

return nil
sess := x.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return fmt.Errorf("sess.Begin: %v", err)
}

// If there was previously a redirect at this location, remove it.
if err = deleteRepoRedirect(sess, u.ID, newRepoName); err != nil {
return fmt.Errorf("delete repo redirect: %v", err)
}

return sess.Commit()
}

func getRepositoriesByForkID(e Engine, forkID int64) ([]*Repository, error) {
Expand Down