summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorMartin Hartkorn <github@hartkorn.net>2016-01-27 22:45:03 +0100
committerMartin Hartkorn <github@hartkorn.net>2016-01-27 22:45:03 +0100
commit674c5c37be53665db8ce549ece51c24129e695d9 (patch)
treed0e7db05da6af34482c0769f12293076801b4d59 /models
parent93f40995b30b67e80e3fff36fe7e7ced756a13d8 (diff)
downloadgitea-674c5c37be53665db8ce549ece51c24129e695d9.tar.gz
gitea-674c5c37be53665db8ce549ece51c24129e695d9.zip
Change user name in Pull Requests
Diffstat (limited to 'models')
-rw-r--r--models/pull.go8
-rw-r--r--models/user.go5
2 files changed, 13 insertions, 0 deletions
diff --git a/models/pull.go b/models/pull.go
index 8497285e16..2fe7d1fe37 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -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,
// and set to be either conflict or mergeable.
func (pr *PullRequest) checkAndUpdateStatus() {
diff --git a/models/user.go b/models/user.go
index 5c43a23a2f..5d8075dbd1 100644
--- a/models/user.go
+++ b/models/user.go
@@ -599,6 +599,11 @@ func ChangeUserName(u *User, newUserName string) (err error) {
return ErrUserAlreadyExist{newUserName}
}
+ err = ChangeUsernameInPullRequests(u.LowerName, newUserName)
+ if err != nil {
+ return err
+ }
+
return os.Rename(UserPath(u.LowerName), UserPath(newUserName))
}