sticky

package
v0.44.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUpdatedBody

func BuildUpdatedBody(oldBody, newBody string, cfg Config) string

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

func TruncateBody(body string, maxSize int) string

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 -->"
	FooterMarker string // optional footer delimiter, stripped before collapsing history
	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
}

Config controls how a sticky comment is identified and managed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL