mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(pr): refuse pr comment and pr attachment on issues
Gitea serves pull request comments and attachments through issue endpoints, so tea pr comment create 1 posted on issue #1. pr comment and pr attachment commands now check that the number is a pull request, and comment IDs that the comment is on one, and point at the issue command otherwise: "#1 in alice/project is an issue, not a pull request; use tea issue comment create 1". Issues gain a kind field (issue or pull) in JSON. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
9 files changed
+150
-10
No files matched your search
@@ -21,6 +21,8 @@ func TestAttachmentCommandsShareIssueAssetsAndPagination(t *testing.T) {
|
||||
_, _ = w.Write([]byte(`[{"id":1,"name":"one"},{"id":2,"name":"two"}]`))
|
||||
case "/api/v1/repos/alice/project/issues/1/assets/1":
|
||||
_, _ = w.Write([]byte(`{"id":1,"name":"one"}`))
|
||||
case "/api/v1/repos/alice/project/issues/1":
|
||||
_, _ = w.Write([]byte(`{"number":1,"pull_request":{}}`))
|
||||
default:
|
||||
t.Fatalf("unexpected path %s", r.URL.Path)
|
||||
}
|
||||
@@ -43,6 +45,10 @@ func TestAttachmentRenameAndConfirmedDeletion(t *testing.T) {
|
||||
for _, group := range []string{"issue", "pr"} {
|
||||
mutations := 0
|
||||
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet && r.URL.Path == "/api/v1/repos/alice/project/issues/1" {
|
||||
_, _ = w.Write([]byte(`{"number":1,"pull_request":{}}`))
|
||||
return
|
||||
}
|
||||
require.Equal(t, "/api/v1/repos/alice/project/issues/1/assets/1", r.URL.Path)
|
||||
mutations++
|
||||
if r.Method == http.MethodPatch {
|
||||
|
||||
Reference in new issue
Block a user