Documentation
¶
Index ¶
- func BuildUpdatedBody(oldBody, newBody string, cfg Config) string
- func FindMarkedComment(comments []forge.IssueComment, marker, botUser string) *forge.IssueComment
- func Post(ctx context.Context, client forge.Client, owner, repo string, number int, ...) (string, error)
- func TruncateBody(body string, maxSize int) string
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildUpdatedBody ¶
BuildUpdatedBody collapses the old comment body into a flat list of <details> blocks and prepends the new body. Footer content (delimited by FooterMarker) is stripped before collapsing and re-appended after.
When cfg.KeepHistory is false, the old body is discarded entirely and the new body is returned with footer re-appended (no "Previous run" blocks).
func FindMarkedComment ¶
func FindMarkedComment(comments []forge.IssueComment, marker, botUser string) *forge.IssueComment
FindMarkedComment returns the first comment whose body contains the given marker string and whose author is exactly botUser, or nil if none is found. An empty botUser matches nothing: callers pass it only when identity resolution failed, and matching on the marker alone would let anyone's comment be treated as the bot's own and edited in-place.
func Post ¶
func Post(ctx context.Context, client forge.Client, owner, repo string, number int, body string, cfg Config, printer *ui.Printer) (string, error)
Post implements the sticky comment lifecycle: find an existing comment bearing the marker, collapse old content into history, and create or update in-place. Returns the HTML URL of the comment (empty on dry run).
It never edits a comment it cannot verify as its own: an existing comment matches only when it carries the marker and its author is exactly the login this client posts as, so a comment anyone could plant with the same marker is ignored. When that login cannot be resolved (after a short retry) it returns an error and posts nothing — not even on dry run, since dry run should not claim an edit would occur when none safely could.
func TruncateBody ¶
TruncateBody trims body to fit within maxSize, keeping the current content at the top and trimming history from the end. The truncation point is aligned to a valid UTF-8 boundary.
Types ¶
type Config ¶
type Config struct {
Marker string // hidden HTML comment, e.g. "<!-- fullsend:review-agent -->"
MaxSize int // max comment body size (default 65000)
DryRun bool
KeepHistory bool // when false, updates replace the body in-place with no "Previous run" history
// TrustedLeadingLine, when set, matches a marker line that the trusted
// caller places as the first line of the body. When the first line of
// the body matches it in full, that line is posted as is and only the
// rest of the body has its marker syntax escaped. A match anywhere else
// is escaped like any other marker. The pattern must be anchored with
// ^ and $ and must not match a line that could carry a second marker.
TrustedLeadingLine *regexp.Regexp
}
Config controls how a sticky comment is identified and managed.