Fix bug when creating pull request (#36166)

Extract from #36105 

Fix #36116
Fix #35912
Fix #20906
This commit is contained in:
Lunny Xiao
2025-12-17 13:21:04 -08:00
committed by GitHub
parent 1e22bd712f
commit efd5dd4f0b
7 changed files with 189 additions and 16 deletions

View File

@@ -1461,3 +1461,15 @@ func GetUserOrOrgIDByName(ctx context.Context, name string) (int64, error) {
}
return id, nil
}
// GetUserOrOrgByName returns the user or org by name
func GetUserOrOrgByName(ctx context.Context, name string) (*User, error) {
var u User
has, err := db.GetEngine(ctx).Where("lower_name = ?", strings.ToLower(name)).Get(&u)
if err != nil {
return nil, err
} else if !has {
return nil, ErrUserNotExist{Name: name}
}
return &u, nil
}