changelog

package
v0.40.21 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package changelog serves Rivolt's release notes: the hand-written notes of each release, as published on its GitHub Release, for the /changelog page and the Atom feed.

The notes are the release body once a person has written it. The body the release starts with is a generated commit list marked AutoNotesMarker, and a release with that body is left out until the notes replace it.

Index

Constants

View Source
const (
	// DefaultURL is the public releases list of the Rivolt repository.
	DefaultURL = "https://api.github.com/repos/apohor/rivolt/releases?per_page=30"
	// AutoNotesMarker starts a generated release body (release-notes.yml).
	AutoNotesMarker = "<!-- rivolt:auto-notes -->"
)

Variables

View Source
var ErrUnavailable = errors.New("changelog: release notes unavailable")

ErrUnavailable is returned when there is no copy to serve: none was ever fetched, and a fetch is running, has just failed, or fails now.

Functions

func Atom

func Atom(rels []Release, now time.Time) ([]byte, error)

Atom renders the releases as an Atom 1.0 feed. Every text goes through encoding/xml, so titles, links and notes are escaped; the notes are carried as text (the Markdown as written), never as HTML.

Types

type Release

type Release struct {
	Tag         string    `json:"tag"`
	PublishedAt time.Time `json:"published_at"`
	Title       string    `json:"title"`
	BodyMD      string    `json:"body_md"`
	URL         string    `json:"url"`
}

Release is one release's notes.

type Source

type Source struct {
	URL  string
	HTTP *http.Client
	TTL  time.Duration
	Now  func() time.Time
	// contains filtered or unexported fields
}

Source fetches the releases from GitHub and keeps them for TTL. A failed refresh serves what it had. Safe for concurrent use.

func New

func New(url string) *Source

New returns a Source for url (DefaultURL when empty).

func (*Source) Releases

func (s *Source) Releases(ctx context.Context) ([]Release, error)

Releases returns the published releases with hand-written notes, newest first. It refreshes from GitHub when the copy is older than TTL. At most one refresh runs at a time, and none for failureBackoff after a failed one; meanwhile callers get the copy, or ErrUnavailable when there is none. So GitHub sees at most one request per TTL, or per backoff while it is failing, however many clients ask.

Jump to

Keyboard shortcuts

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