prroute

package
v0.107.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prroute is deterministic PULL-REQUEST → SESSION routing's pure half: which pull request a review mail is about (ParseMail), and the shape of an authorship report (Signal) — which pull request a session created, or which branch it pushed — as a host's PostToolUse hook sends it to POST /api/pr-sessions (internal/api/pr_routes.go). It holds no store and makes no network call. docs/plugins.md#a-pull-request-review-mail.

Index

Constants

This section is empty.

Variables

View Source
var (
	// RepoPattern is a repository as the mail and a transcript name it.
	RepoPattern = regexp.MustCompile(`^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$`)
)

Functions

func ValidRef

func ValidRef(s string) bool

ValidRef reports whether s is a branch name this feature stores.

Types

type Kind

type Kind string

Kind is how a session authored a pull request.

const (
	// KindPRCreate: the session ran `gh pr create`, which printed the new pull
	// request's URL.
	KindPRCreate Kind = "gh-pr-create"
	// KindPush: the session ran `git push`, which named the remote repository
	// and a branch it updated.
	KindPush Kind = "git-push"
)

type Ref

type Ref struct {
	// Repo is "<owner>/<repo>", lower-cased (GitHub's names are case-insensitive).
	Repo string
	// PR is the pull request's number.
	PR int64
	// HeadSHA is the reviewed head commit (40 lower-case hex).
	HeadSHA string
	// HeadRef is the pull request's head branch, "" when the mail names none.
	HeadRef string
}

Ref is the pull request a review mail names.

func ParseMail

func ParseMail(body string) (Ref, bool)

ParseMail is the pull request mail body names, read from the LAST fenced ```json block of the body. ok is false for anything malformed — no such block, invalid JSON, a missing or invalid repo, pr or head_sha, or a head_ref that is present and not a branch name — and the caller then routes nothing by it.

🔴 THE LAST BLOCK DECIDES, AND AN EARLIER ONE IS NEVER A FALLBACK: the gate writes its machine-readable block last, and a body may quote other JSON before it (a finding's excerpt). A fence is matched as CommonMark matches it — closed only by a backtick run at least as long as the one that opened it — so a block the gate fenced with more backticks than any run inside it is read whole, and a fenced block of another kind hides what is inside it.

type Signal

type Signal struct {
	Kind    Kind
	Repo    string
	PR      int64
	HeadRef string
}

Signal is one authorship report: Repo and PR for KindPRCreate (HeadRef too when the create named its head branch), Repo and HeadRef for KindPush.

func (Signal) Valid

func (s Signal) Valid() bool

Valid reports whether s is a well-formed report: a known kind, a repo, a positive PR for a create (none for a push), a branch for a push (optional for a create), each in this package's grammar.

Jump to

Keyboard shortcuts

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