- page/limit defaulting tested stale 'ok' from earlier type assertion
(list_repo_pull_requests, list_repo_commits, check_notifications,
list_repo_notifications) — now zero-default like all other handlers
- list_repo_issues: wire 'type' filter to SDK ListIssueOption.Type
- list_repo_pull_requests: wire 'milestone' to opt.Milestone; drop
unimplementable 'labels' param from schema (SDK has no labels filter)
- search_users / search_org_teams: honor page/limit via ListOptions
- delete_file: forward new_branch_name to FileOptions
- label resources: parse documented {?page,limit} query (cap 30) + tests
- cmd: -d/-debug default true→false; FORGEJO_DEBUG fallback reachable
- resources: rune-safe 200-byte excerpts via resource.Excerpt + tests
- docs: DoJSON isList comment, validateSHA lowercase claim
Closes beads: fcm 9ii cdf 3nu tc6 7f8 r7h cv4 yea
18 lines
380 B
Go
18 lines
380 B
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package resource
|
|
|
|
import "unicode/utf8"
|
|
|
|
// Excerpt truncates s to at most max bytes without splitting a UTF-8 rune,
|
|
// appending an ellipsis when truncation happened.
|
|
func Excerpt(s string, max int) string {
|
|
if len(s) <= max {
|
|
return s
|
|
}
|
|
cut := max
|
|
for cut > 0 && !utf8.RuneStart(s[cut]) {
|
|
cut--
|
|
}
|
|
return s[:cut] + "…"
|
|
}
|