-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix stange behavior of DownloadPullDiffOrPatch in incorect index #17223
Conversation
* validate index Signed-off-by: Danila Kryukov <pricly_yellow@dismail.de>
Codecov Report
@@ Coverage Diff @@
## main #17223 +/- ##
==========================================
- Coverage 45.31% 45.25% -0.07%
==========================================
Files 773 779 +6
Lines 86873 87287 +414
==========================================
+ Hits 39366 39501 +135
- Misses 41151 41369 +218
- Partials 6356 6417 +61
Continue to review full report at Codecov.
|
suggest update test code: diff --git a/models/pull_test.go b/models/pull_test.go
index 2b7ef2f66..173977aaf 100644
--- a/models/pull_test.go
+++ b/models/pull_test.go
@@ -134,6 +134,10 @@ func TestGetPullRequestByIndex(t *testing.T) {
_, err = GetPullRequestByIndex(9223372036854775807, 9223372036854775807)
assert.Error(t, err)
assert.True(t, IsErrPullRequestNotExist(err))
+
+ _, err = GetPullRequestByIndex(1, 0)
+ assert.Error(t, err)
+ assert.True(t, IsErrPullRequestNotExist(err))
}
func TestGetPullRequestByID(t *testing.T) {
|
Co-authored-by: a1012112796 <1012112796@qq.com>
Good idea, push it now |
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.
Apart from this question: LGTM.
the (xorm) Get will ignore fields with "default init values" and match with set one var value int64
fmt.Println(value) That's why Get is mostly used with the ".ID()" function witch we can not use since So either check with if if it is 0 and return 404 or add a explisit Where("index=?", pr.index). In this case an if is more elegant since 0 is not an valide index @delvh (:point_up:) |
@pricly-yellow thanks for the pull, can you cherry-pick squash-commit to release branch 1.15 and make a pull? if you need help just tell |
-> #17227 |
) (#17227) Fix GetPullRequestByIndex by validate index > 1 Signed-off-by: Danila Kryukov <pricly_yellow@dismail.de> Co-authored-by: a1012112796 <1012112796@qq.com>
…gitea#17223) Fix GetPullRequestByIndex by validate index > 1 Signed-off-by: Danila Kryukov <pricly_yellow@dismail.de> Co-authored-by: a1012112796 <1012112796@qq.com>
Close #17105