From e68aa07ca564e4be24049f24eeec797e1ee29658 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Tue, 22 Apr 2025 00:35:20 +0300 Subject: [PATCH] knotserver: add format_patch capability --- appview/state/pull.go | 5 +++++ knotserver/routes.go | 1 + types/capabilities.go | 1 + 3 files changed, 7 insertions(+) diff --git a/appview/state/pull.go b/appview/state/pull.go index fc04a99a..338452a8 100644 --- a/appview/state/pull.go +++ b/appview/state/pull.go @@ -670,6 +670,11 @@ func (s *State) NewPull(w http.ResponseWriter, r *http.Request) { return } + if !caps.PullRequests.FormatPatch { + s.pages.Notice(w, "pull", "This knot doesn't support format-patch. Unfortunately, there is no fallback for now.") + return + } + // Handle the PR creation based on the type if isBranchBased { if !caps.PullRequests.BranchSubmissions { diff --git a/knotserver/routes.go b/knotserver/routes.go index 9b6cd47b..3f390a28 100644 --- a/knotserver/routes.go +++ b/knotserver/routes.go @@ -37,6 +37,7 @@ func (h *Handle) Capabilities(w http.ResponseWriter, r *http.Request) { capabilities := map[string]any{ "pull_requests": map[string]any{ + "format_patch": true, "patch_submissions": true, "branch_submissions": true, "fork_submissions": true, diff --git a/types/capabilities.go b/types/capabilities.go index 2e81670d..281238ed 100644 --- a/types/capabilities.go +++ b/types/capabilities.go @@ -2,6 +2,7 @@ package types type Capabilities struct { PullRequests struct { + FormatPatch bool `json:"format_patch"` PatchSubmissions bool `json:"patch_submissions"` BranchSubmissions bool `json:"branch_submissions"` ForkSubmissions bool `json:"fork_submissions"` -- 2.51.2