Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.3k
Refactor compare router param parse#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 ourterms of service andprivacy 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
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: techknowlogick <techknowlogick@gitea.io>Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
a1012112796 commentedDec 10, 2025
please have a look at#36116 |
lunny commentedDec 11, 2025
This has been included and it's ready to review now. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
| ifrouterParam=="" { | ||
| return&CompareRouterReq{},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.
Is it valid argument?
What will&CompareRouterReq{} compare?
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.
It's valid. Then both base repository and head repository are the same. The base branch and head branch are the default branch of base repository. The behavior is the same as Github. i.e.https://github.com/go-gitea/gitea/compare
routers/web/repo/compare.go Outdated
| ci.BaseBranch=util.Iif(compareReq.BaseOriRef=="",baseRepo.DefaultBranch,compareReq.BaseOriRef) | ||
| ci.HeadBranch=util.Iif(compareReq.HeadOriRef=="",ci.HeadRepo.DefaultBranch,compareReq.HeadOriRef) | ||
| ci.DirectComparison=compareReq.DirectComparison() |
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 just useci (parse the route parameter intoCompareInfo) ? What's the purpose of passingcompareReq intoci?
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.
It's easier to write the unit test for the router param parsing.
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.
Don't see why it is "easier"
Now you have 3 different structs for the same purpose:
- CompareRouterReq
- parseCompareInfoResult
- CompareInfo
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.
TheGetCompareInfo will be used without a compare router parsing, so I think it's better to keep it as two functions. I extract bugs fix to another PR and will only keep refactor code here. I also sent04e7382 to merge the 3 compare info structures.
Uh oh!
There was an error while loading.Please reload this page.
Bugs fix extracted to#36166