Browse Source

Change user name in Pull Requests

tags/v0.9.99
Martin Hartkorn 8 years ago
parent
commit
674c5c37be
2 changed files with 13 additions and 0 deletions
  1. 8
    0
      models/pull.go
  2. 5
    0
      models/user.go

+ 8
- 0
models/pull.go View File

} }
} }


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() {

+ 5
- 0
models/user.go View File

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…
Cancel
Save