format

package
v0.0.0-...-229e418 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package format provides PR message formatting for Discord.

Index

Constants

View Source
const (
	EmojiNewlyPublished = "\U0001F195"   // 🆕 Newly published
	EmojiDraft          = "\U0001F6A7"   // 🚧 Draft (construction)
	EmojiTestsRunning   = "\U0001F9EA"   // 🧪 Tests running
	EmojiTestsBroken    = "\U0001FAB3"   // 🪳 Tests failing (cockroach)
	EmojiAwaitingAssign = "\U0001F937"   // 🤷 Awaiting assignment
	EmojiNeedsReview    = "\u23F3"       // ⏳ Needs review (hourglass)
	EmojiChanges        = "\U0001FA9A"   // 🪚 Changes requested (saw)
	EmojiApproved       = "\u2705"       // ✅ Approved
	EmojiMerged         = "\U0001F680"   // 🚀 Merged
	EmojiClosed         = "\u274C"       // ❌ Closed
	EmojiConflict       = "\u26A0\uFE0F" // ⚠️ Merge conflict
	EmojiUnknown        = "\U0001F4EF"   // 📯 Unknown state (postal horn)
)

PR state emoji mappings.

Variables

This section is empty.

Functions

func ActionGroups

func ActionGroups(users []ActionUser) string

ActionGroups groups users by action and formats them. Returns format like: "**review** → @alice, @bob; **approve** → @charlie".

func ActionLabel

func ActionLabel(action string) string

ActionLabel returns a human-readable label for an action. Converts snake_case to space-separated words (matching Slacker format).

func ChannelMessage

func ChannelMessage(p ChannelMessageParams) string

ChannelMessage formats a PR notification for a text channel.

func DMMessage

func DMMessage(p ChannelMessageParams, action string) string

DMMessage formats a DM notification.

func ForumThreadTitle

func ForumThreadTitle(repo string, number int, title string) string

ForumThreadTitle formats the title for a forum thread.

func StateEmoji

func StateEmoji(state PRState) string

StateEmoji returns the emoji for a PR state.

func StateText

func StateText(state PRState) string

StateText returns the human-readable text label for a PR state. Returns empty string for states that don't need text labels.

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen, adding "..." if truncated.

Types

type ActionUser

type ActionUser struct {
	Username string
	Mention  string // Discord mention format or plain username
	Action   string // e.g., "review", "approve", "fix tests"
}

ActionUser represents a user who needs to take action.

type ChannelMessageParams

type ChannelMessageParams struct {
	Owner       string
	Repo        string
	Title       string
	Author      string
	State       PRState
	PRURL       string
	ChannelName string
	ActionUsers []ActionUser
	Number      int
}

ChannelMessageParams contains parameters for formatting a channel message.

type PRState

type PRState string

PRState represents the simplified state of a PR for formatting.

const (
	StateNewlyPublished PRState = "newly_published"
	StateDraft          PRState = "draft"
	StateTestsRunning   PRState = "tests_running"
	StateTestsBroken    PRState = "tests_broken"
	StateAwaitingAssign PRState = "awaiting_assignment"
	StateNeedsReview    PRState = "needs_review"
	StateChanges        PRState = "changes_requested"
	StateApproved       PRState = "approved"
	StateMerged         PRState = "merged"
	StateClosed         PRState = "closed"
	StateConflict       PRState = "conflict"
	StateUnknown        PRState = "unknown"
)

PR state constants.

func StateFromAnalysis

func StateFromAnalysis(p StateAnalysisParams) PRState

StateFromAnalysis determines PRState from Turn API analysis. This matches slacker's extractStateFromTurnclient logic.

type StateAnalysisParams

type StateAnalysisParams struct {
	WorkflowState      string
	ChecksFailing      int
	ChecksPending      int
	ChecksWaiting      int
	UnresolvedComments int
	Merged             bool
	Closed             bool
	Draft              bool
	MergeConflict      bool
	Approved           bool
}

StateAnalysisParams contains parameters for StateFromAnalysis.

Jump to

Keyboard shortcuts

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