-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Refactor compare router param parse and fix bugs #36105
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: techknowlogick <techknowlogick@gitea.io> Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
|
please have a look at #36116 |
This has been included and it's ready to review now. |
models/user/user.go
Outdated
|
|
||
| func GetUserOrOrgByName(ctx context.Context, name string) (*User, error) { | ||
| var u User | ||
| has, err := db.GetEngine(ctx).Where("name = ?", name).Get(&u) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not
lower_name - There is no existing similar function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6453e4a There is no existing function that can retrieve a user or an organization.
routers/api/v1/repo/pull.go
Outdated
| return nil, nil | ||
| } | ||
| if headRepo == nil { | ||
| ctx.HTTPError(http.StatusBadRequest, "The user "+headOwner.Name+" does not have a fork of the base repository") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sometimes APIError sometimes HTTPError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
routers/web/repo/compare.go
Outdated
| } else { | ||
| ctx.ServerError("GetRepositoryByName", err) | ||
| } | ||
| return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why duplicate the code with API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
routers/api/v1/repo/pull.go
Outdated
| } else { | ||
| headOwner, err = user_model.GetUserOrOrgByName(ctx, compareReq.HeadOwner) | ||
| if err != nil { | ||
| if user_model.IsErrUserNotExist(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetUserOrOrgByName doesn't return errors for IsErrUserNotExist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Is it safe to backport a refactoring PR with so many logic changes? |
This will be partially backport. Only bugfixes will be backport. |
Fix #36116
Fix #35912
Fix #20906