forked from NYANDEV/forgejo
Merge pull request #2494 from mhartkorn/pullreq-name-change
Change user name in Pull Requests to avoid errors (fixes #2495)
This commit is contained in:
commit
0617720c0c
2 changed files with 13 additions and 0 deletions
|
@ -525,6 +525,14 @@ func AddTestPullRequestTask(repoID int64, branch string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ChangeUsernameInPullRequests(oldUserName, newUserName string) (error) {
|
||||||
|
pr := PullRequest{
|
||||||
|
HeadUserName : newUserName,
|
||||||
|
}
|
||||||
|
_, err := x.Cols("head_user_name").Where("head_user_name = ?", oldUserName).Update(pr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// checkAndUpdateStatus checks if pull request is possible to levaing checking status,
|
// checkAndUpdateStatus checks if pull request is possible to levaing checking status,
|
||||||
// and set to be either conflict or mergeable.
|
// and set to be either conflict or mergeable.
|
||||||
func (pr *PullRequest) checkAndUpdateStatus() {
|
func (pr *PullRequest) checkAndUpdateStatus() {
|
||||||
|
|
|
@ -599,6 +599,11 @@ func ChangeUserName(u *User, newUserName string) (err error) {
|
||||||
return ErrUserAlreadyExist{newUserName}
|
return ErrUserAlreadyExist{newUserName}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = ChangeUsernameInPullRequests(u.LowerName, newUserName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return os.Rename(UserPath(u.LowerName), UserPath(newUserName))
|
return os.Rename(UserPath(u.LowerName), UserPath(newUserName))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue