Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Dec 8, 2025

Fix #36116
Fix #35912
Fix #20906

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Dec 8, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 8, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Dec 8, 2025
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
@a1012112796
Copy link
Member

please have a look at #36116

@lunny lunny marked this pull request as ready for review December 10, 2025 23:25
@lunny lunny changed the title Refactor compare router param parse Refactor compare router param parse and fix bugs Dec 11, 2025
@lunny
Copy link
Member Author

lunny commented Dec 11, 2025

please have a look at #36116

This has been included and it's ready to review now.

@lunny lunny added the type/bug label Dec 11, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 11, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 12, 2025

func GetUserOrOrgByName(ctx context.Context, name string) (*User, error) {
var u User
has, err := db.GetEngine(ctx).Where("name = ?", name).Get(&u)
Copy link
Contributor

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?

Copy link
Member Author

@lunny lunny Dec 12, 2025

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.

return nil, nil
}
if headRepo == nil {
ctx.HTTPError(http.StatusBadRequest, "The user "+headOwner.Name+" does not have a fork of the base repository")
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
ctx.ServerError("GetRepositoryByName", err)
}
return nil
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
headOwner, err = user_model.GetUserOrOrgByName(ctx, compareReq.HeadOwner)
if err != nil {
if user_model.IsErrUserNotExist(err) {
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wxiaoguang wxiaoguang marked this pull request as draft December 12, 2025 02:54
@wxiaoguang
Copy link
Contributor

Is it safe to backport a refactoring PR with so many logic changes?

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Dec 12, 2025
@GiteaBot GiteaBot removed the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Dec 12, 2025
@lunny
Copy link
Member Author

lunny commented Dec 12, 2025

Is it safe to backport a refactoring PR with so many logic changes?

This will be partially backport. Only bugfixes will be backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/translation type/bug type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

7 participants