From 7f09c1c07071a7905c97c66568916d3a82c6ef10 Mon Sep 17 00:00:00 2001 From: adssib <75389300+adssib@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:04:04 -0500 Subject: [PATCH 1/3] changelog: read SDK changelogs, release notes and tag-listed releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The classifier reads the SDK changelogs' shapes: release-please's "⚠ BREAKING CHANGES", changesets' "Major Changes", Stripe's ⚠️ bullets, "**[BREAKING]**" and "feat!:" marks, an area, issue or commit a bullet starts with, passive removals and renames from an owner, and semantic- release's "# [X.0.0]" major headings. A File can read each GitHub release's notes (Notes), list releases from the repo's tags for an ecosystem with no registry lister, and names a Go module at its major. Co-Authored-By: Claude Opus 5.5 Signed-off-by: adssib <75389300+adssib@users.noreply.github.com> --- AGENTS.md | 2 +- docs/which-kind.md | 2 +- docs/writing-a-plugin.md | 2 +- plugins/changelog/changelog.go | 135 +++++++++++++++--- plugins/changelog/changelog_test.go | 35 +++++ plugins/changelog/classify.go | 63 ++++++-- plugins/changelog/parse.go | 44 ++++-- plugins/changelog/parse_test.go | 13 ++ plugins/changelog/testdata/README.md | 1 + .../versions/octokit-rest-releases.json | 6 + .../testdata/versions/stripe-go-tags.json | 7 + plugins/changelog/versions_test.go | 29 ++++ 12 files changed, 291 insertions(+), 48 deletions(-) create mode 100644 plugins/changelog/testdata/versions/octokit-rest-releases.json create mode 100644 plugins/changelog/testdata/versions/stripe-go-tags.json diff --git a/AGENTS.md b/AGENTS.md index fbf9895..8f54e2e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -61,7 +61,7 @@ core/event/ the change event of patch-it's contract: types, fingerpri core/diff/ core/normalize/ core/hint/ the OpenAPI diff engine and its helpers plugins// one package per kind, with its providers: openapi (+ adapter/, one spec adapter per provider), notices (+ retire/, feed/, eol/), migrationguide (+ sdkguide/, - members/), changelog (Markdown, RST or JSON), catalog, apisurface (+ pysurface/); + members/), changelog (Markdown, RST, GitHub release notes or JSON), catalog, apisurface (+ pysurface/); plugins/all imports every one cmd/list-plugins/ prints the list from the registry (make plugins); internal/pluginlist/ is its logic cmd/new-plugin/ scaffolds a provider's source on a kind (make new-plugin ARGS=...; go run ./cmd/new-plugin --help) diff --git a/docs/which-kind.md b/docs/which-kind.md index f2f67c9..aa860e9 100644 --- a/docs/which-kind.md +++ b/docs/which-kind.md @@ -10,7 +10,7 @@ Every kind is one of two shapes ([writing-a-plugin.md, step 4](writing-a-plugin. |---|---|---|---| | Does the provider publish an **OpenAPI spec** of its API, per release or per commit? | `openapi` | Two specs, diffed: removed and renamed operations, parameters, fields; deprecations | A spec repo with release tags; a spec file a repo commits on every change | | Is there a **guide that lists what a release removed**, one per major or per release, in a table? | `migrationguide` | The guide at the release's tag: removed request parameters (reader `sdk`) or removed members of a module (reader `members`, RST or Markdown tables) | `MIGRATION.md` per major; "removed members" tables in a 2.0 migration guide; an API version removal guide | -| Is there a **changelog**: a file per release (`CHANGELOG.md`, `CHANGES.rst`, `HISTORY.rst`), or a machine-readable JSON changelog? | `changelog` | The release's section at its tag (reader `markdown`), or the life-cycle entries a JSON changelog adds commit by commit (reader `json`) | Keep a Changelog files; reStructuredText release notes; an API changelog JSON in a repo; a Terraform provider's changelog | +| Is there a **changelog**: a file per release (`CHANGELOG.md`, `CHANGES.rst`, `HISTORY.rst`), release notes on each GitHub release, or a machine-readable JSON changelog? | `changelog` | The release's section at its tag, or the tag's GitHub release notes (`Notes: true`) (reader `markdown`), or the life-cycle entries a JSON changelog adds commit by commit (reader `json`) | Keep a Changelog files; release-please and changesets changelogs; reStructuredText release notes; an SDK with only GitHub release notes; an API changelog JSON in a repo; a Terraform provider's changelog | | Is there a **live page of dated notices**: a deprecations or shutdown table, an end-of-life table, or an **RSS/Atom feed** of announcements? | `notices` | The page as it is now, cited through a Web Archive snapshot, against the snapshot kept from the read before: a living page, with no versions of its own (reader `deprecations`, `feed`, or an end-of-life table) | A model deprecations page; an API end-of-life policy table; a changelog feed with a "deprecation" label; a Kubernetes API removals page | | Is there a **flat catalog**, one JSON entry per name (a command, an endpoint), with no release tags? | `catalog` | Two snapshots, compared for names that disappeared entirely | A list of commands a server accepts, kept in a repo | | Is it a **published package** with no changelog worth reading? | `apisurface` | Each release's files from the registry (PyPI first), compared: removed or renamed classes, functions, methods, and parameters removed or newly required | An SDK generated from a spec, released often, whose changelog says "chore: update types" | diff --git a/docs/writing-a-plugin.md b/docs/writing-a-plugin.md index 01b4ea7..5c0023a 100644 --- a/docs/writing-a-plugin.md +++ b/docs/writing-a-plugin.md @@ -85,7 +85,7 @@ Write the numbers on the provider page, as `providers/vercel.md` does for its sp | `plugins/openapi` | An OpenAPI spec per release, diffed with `core/diff/` and turned into events by `core/normalize/` | An `adapter.Adapter` in `plugins/openapi/adapter/` (latest tag, fetch a tag's spec; `Versions` to list every release) and a `plugin.RegisterProvider` block | | `plugins/notices` | A live page of dated notices: a model provider's deprecations page (a table of date, model, replacement), a vendor's RSS or Atom feed, a vendor's table of whole API version ranges and their support status | A `retire.Page` in `plugins/notices/retire/providers.go`, a `feed.Feed` with a reader for that vendor's entries in `plugins/notices/feed/`, or an `eol.Page` in `plugins/notices/eol/` (`new-plugin` doesn't scaffold this reader yet) | | `plugins/migrationguide` | A guide that lists what a release removed, at the release's tag: an SDK's migration guide per new major (removed request parameters), or a package's table of removed members (an RST simple table or a Markdown pipe table) | A `sdkguide.Guide` in `plugins/migrationguide/sdkguide/`, or a `members.Guide` in `plugins/migrationguide/members/` | -| `plugins/changelog` | A changelog: a `CHANGELOG.md` / `CHANGES.rst` / `HISTORY.rst`, each release's section at its tag (releases from PyPI or npm), or a vendor's machine-readable API changelog in JSON (per day, endpoint and API version, oasdiff change codes), commit by commit | A `changelog.File` with its `TagPrefix`, or a `changelog.Log` | +| `plugins/changelog` | A changelog: a `CHANGELOG.md` / `CHANGES.rst` / `HISTORY.rst`, each release's section at its tag (releases from PyPI or npm, or for any other ecosystem the repo's `TagPrefix` + X.Y.Z tags), or each GitHub release's notes (`Notes`), or a vendor's machine-readable API changelog in JSON (per day, endpoint and API version, oasdiff change codes), commit by commit | A `changelog.File` with its `Ecosystem` and `TagPrefix`, or a `changelog.Log` | | `plugins/catalog` | A flat JSON catalog, one entry per name, with no release tags to pin — a commit SHA stands in | A `catalog.Catalog`, diffed between two snapshots for names that disappeared entirely | | `plugins/apisurface` | A published package's public API, compared between two releases: the classes, functions, methods and parameters in each release's files (Python first: the wheel or sdist from PyPI) | A `apisurface.Package` (registry name, ecosystem, top-level module) and its `plugin.RegisterProvider` block | diff --git a/plugins/changelog/changelog.go b/plugins/changelog/changelog.go index 90a8a63..0d4d44f 100644 --- a/plugins/changelog/changelog.go +++ b/plugins/changelog/changelog.go @@ -1,17 +1,22 @@ // Package changelog is the kind for a changelog, with a parser for each -// shape: a package's changelog file in Markdown or reStructuredText (File; -// this file, parse.go, classify.go), or a vendor's machine-readable API -// changelog in JSON (Log; json.go). One Plugin reads either. +// shape: a package's changelog file in Markdown or reStructuredText, or its +// release notes on GitHub (File; this file, parse.go, classify.go), or a +// vendor's machine-readable API changelog in JSON (Log; json.go). One Plugin +// reads either. // -// A changelog file (CHANGELOG.md, CHANGES.rst, HISTORY.rst) is read at a release's tag: one -// change event per bullet that plainly removes, renames or deprecates names -// code uses. The tag never changes, so its URL is the event's provenance (no +// A changelog file (CHANGELOG.md, CHANGES.rst, HISTORY.rst) is read at a +// release's tag, and a release's notes at its tag's GitHub release: one change +// event per bullet that plainly removes, renames or deprecates names code +// uses. The tag never changes, so its URL is the event's provenance (no // snapshot) and a rerun stores nothing new: the fingerprints dedupe. // // Which bullets count: those under a Keep a Changelog "Removed" or // "Deprecated" heading, and the common variants ("Breaking changes", -// "Backwards incompatible changes", "Deprecations", reStructuredText titles, -// "**Deprecations**:"), plus a "Breaking change:" bullet under any heading. +// "⚠ BREAKING CHANGES", "Backwards incompatible changes", "Deprecations", +// changesets' "Major Changes", reStructuredText titles, "**Deprecations**:"), +// plus a bullet marked breaking under any heading ("Breaking change:", "⚠️", +// "**[BREAKING]**", "feat!:"). An area, issue or commit the bullet starts +// with ("**client:**", "[#12](...)", "abc1234:") is read past. // A bullet must say which names in one plain sentence ("Removed `X`", // "`X` class removed", "Deprecated `X` in favor of `Y`"); anything else // (dropped Python versions, behavior changes, parameters of an unnamed call, @@ -20,8 +25,12 @@ package changelog import ( "context" + "encoding/json" "fmt" "log" + "net/url" + "regexp" + "slices" "strings" "github.com/patch-it-dev/patch-it-plugins/core/event" @@ -62,16 +71,21 @@ func init() { } // File is one package's changelog. Unpinned (Tag and Release empty), it is -// read release by release: every version on the package registry, the file at -// that release's tag (TagPrefix + version). Pinned (At), it is one release. +// read release by release: every version on the package registry (PyPI, npm) +// or, for an ecosystem patch-it doesn't list (Go, Maven, NuGet, RubyGems, +// Packagist, Terraform), every TagPrefix + X.Y.Z tag in the repo; the file at +// that release's tag. With Notes, the changelog is each release's notes on +// GitHub instead of a file, and the versions are the repo's releases. Pinned +// (At), it is one release. type File struct { API string // the source id the events carry: "urllib3/urllib3" - Package string // the installed name: "urllib3" - Ecosystem string // where its releases are listed: "pypi" + Package string // the installed name: "urllib3"; a Go module's path without its /vN + Ecosystem string // where it's installed from: "pypi", "npm", "go", "maven", "nuget", "rubygems", "packagist", "terraform" Module string // the import name, stripped from a symbol's front: "urllib3" Repo string // owner/name on GitHub TagPrefix string // a release's git tag is TagPrefix + its version: "v" for v0.86.0 Path string // the changelog's path in the repo + Notes bool // the changelog is each GitHub release's notes, not a file Tag string // pinned: the release's tag: "2.0.0", "v0.86.0" Release string // pinned: the release as the changelog heads it: "2.0.0" } @@ -104,11 +118,41 @@ var ( Urllib3200 = Urllib3.At("2.0.0") ) -// URL is the changelog as it was at the (pinned) tag: its own provenance. +// URL is what ReadAt fetches: the changelog as it was at the (pinned) tag, +// or the tag's release on GitHub's API. func (f File) URL() string { + if f.Notes { + return fmt.Sprintf("%s/repos/%s/releases/tags/%s", versions.GitHubAPI, f.Repo, url.PathEscape(f.Tag)) + } return fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/%s", f.Repo, f.Tag, f.Path) } +// Cite is the events' provenance: the file at the tag, or the release's +// page, where a person reads the same notes. +func (f File) Cite() string { + if f.Notes { + return fmt.Sprintf("https://github.com/%s/releases/tag/%s", f.Repo, url.PathEscape(f.Tag)) + } + return f.URL() +} + +// what the changelog is, in a sentence. +func (f File) what() string { + if f.Notes { + return "release notes" + } + return "changelog" +} + +// installed is the package as code installs it at the release: a Go +// module's path gains /vN from major 2 on (Go's semantic import versioning). +func (f File) installed() string { + if m := versions.Major(f.Release); f.Ecosystem == "go" && m >= 2 { + return fmt.Sprintf("%s/v%d", f.Package, m) + } + return f.Package +} + // Finding is one bullet that became a change, or one that was dropped. type Finding struct { Change Change @@ -119,7 +163,12 @@ type Finding struct { // Read finds the release's breaking and deprecation bullets. func (f File) Read(page []byte) (heading string, out []Finding, err error) { - heading, sections, err := ReleaseNotes(page, f.Release) + var sections []Section + if f.Notes { + heading, sections, err = f.notes(page) + } else { + heading, sections, err = ReleaseNotes(page, f.Release) + } if err != nil { return "", nil, err } @@ -144,6 +193,30 @@ func (f File) Read(page []byte) (heading string, out []Finding, err error) { return heading, out, nil } +// notes are the sections of a GitHub release's body (the API's JSON for one +// release), headed by its name. A release with no notes has nothing to read. +func (f File) notes(page []byte) (string, []Section, error) { + var r struct { + Tag string `json:"tag_name"` + Name string `json:"name"` + Body string `json:"body"` + } + if err := json.Unmarshal(page, &r); err != nil { + return "", nil, fmt.Errorf("parsing the release %s: %w", f.Tag, err) + } + if r.Tag != f.Tag { + return "", nil, fmt.Errorf("the release read is %q, not %q", r.Tag, f.Tag) + } + if strings.TrimSpace(r.Body) == "" { + return "", nil, fmt.Errorf("release %s has no notes: %w", f.Tag, plugin.ErrNothingToRead) + } + heading := r.Name + if heading == "" { + heading = r.Tag + } + return heading, NotesSections(r.Body), nil +} + // added are the names the release's "Added" bullets name, as symbols. func (f File) added(sections []Section) map[string]bool { out := map[string]bool{} @@ -194,13 +267,24 @@ func (p Plugin) ListVersions(ctx context.Context, env plugin.Env) ([]plugin.Vers } var vs []plugin.Version var err error - switch f.Ecosystem { - case "pypi": + switch { + case f.Notes: + vs, err = versions.GitHubReleases(ctx, env.Get, f.Repo, func(tag string) bool { + v, ok := strings.CutPrefix(tag, f.TagPrefix) + return ok && versions.Final(v) && !strings.HasPrefix(v, "v") + }) + for i := range vs { + vs[i].ID = strings.TrimPrefix(vs[i].Ref, f.TagPrefix) + } + slices.SortStableFunc(vs, func(a, b plugin.Version) int { return versions.Compare(a.ID, b.ID) }) + return vs, err + case f.Ecosystem == "pypi": vs, err = versions.PyPIReleases(ctx, env.Get, f.Package) - case "npm": + case f.Ecosystem == "npm": vs, err = versions.NPMReleases(ctx, env.Get, f.Package) default: - return nil, fmt.Errorf("%s: no registry to list %q releases from", f.Package, f.Ecosystem) + // No registry patch-it lists from: the repo's release tags. + return versions.GitHubTags(ctx, env.Get, f.Repo, regexp.MustCompile(`^`+regexp.QuoteMeta(f.TagPrefix)+`(\d+(?:\.\d+)+)$`)) } if err != nil { return nil, err @@ -222,7 +306,7 @@ func (p Plugin) ReadAt(ctx context.Context, env plugin.Env, v plugin.Version) (p if err != nil { return plugin.Snapshot{}, fmt.Errorf("fetching %s: %w", f.URL(), err) } - return plugin.Snapshot{Version: v, Content: page, SourceURL: f.URL()}, nil + return plugin.Snapshot{Version: v, Content: page, SourceURL: f.Cite()}, nil } // Extract is the to release's section of the changelog: an event per bullet @@ -237,11 +321,12 @@ func (p Plugin) Extract(_ context.Context, env plugin.Env, from, to plugin.Snaps f.Release, f.Tag = to.Version.ID, to.Version.Ref heading, findings, err := f.Read(to.Content) if err != nil { - return plugin.Result{}, fmt.Errorf("reading %s: %w", f.URL(), err) + return plugin.Result{}, fmt.Errorf("reading %s: %w", f.Cite(), err) } now := env.Now().UTC() var events []event.Event var rejected []error + seen := map[string]bool{} // a changelog that lists a bullet twice is one change for _, fd := range findings { if fd.Dropped != "" { log.Printf("%s %s: dropped %q: %s", f.Package, f.Release, fd.Bullet.Text, fd.Dropped) @@ -249,7 +334,7 @@ func (p Plugin) Extract(_ context.Context, env plugin.Env, from, to plugin.Snaps } c := fd.Change subject := event.Subject{ - Type: event.SubjectPackageRelease, Ecosystem: f.Ecosystem, Package: f.Package, + Type: event.SubjectPackageRelease, Ecosystem: f.Ecosystem, Package: f.installed(), Change: c.Change, Symbols: c.Symbols, Replacement: c.Replacement, } e := event.Event{ @@ -260,13 +345,17 @@ func (p Plugin) Extract(_ context.Context, env plugin.Env, from, to plugin.Snaps Breaking: c.ChangeType == event.ChangeTypeBreaking, Subject: subject, Description: describe(f, c), - MigrationHint: cap2000(fmt.Sprintf("%s (%s's changelog for %s)", fd.Bullet.Text, f.Package, f.Release)), - SourceURL: f.URL(), + MigrationHint: cap2000(fmt.Sprintf("%s (%s's %s for %s)", fd.Bullet.Text, f.Package, f.what(), f.Release)), + SourceURL: f.Cite(), SourceExcerpt: cap2000(heading + "\n" + fd.Section + "\n" + fd.Bullet.Raw), Confidence: 1.0, DetectedAt: now, } e.Fingerprint = event.Fingerprint(e.API, e.Version, e.ChangeType, subject, "") + if seen[e.Fingerprint] { + continue + } + seen[e.Fingerprint] = true if err := e.Validate(); err != nil { rejected = append(rejected, fmt.Errorf("%s %s %v: %w", f.Package, f.Release, c.Symbols, err)) continue diff --git a/plugins/changelog/changelog_test.go b/plugins/changelog/changelog_test.go index 6dc9088..86114fa 100644 --- a/plugins/changelog/changelog_test.go +++ b/plugins/changelog/changelog_test.go @@ -2,6 +2,7 @@ package changelog import ( "context" + "errors" "strings" "testing" @@ -95,3 +96,37 @@ func TestUnsureBulletsAreDropped(t *testing.T) { } } } + +// A Go module's events name the module as code imports it at that major. +func TestAGoModuleIsNamedByItsMajor(t *testing.T) { + f := File{Package: "github.com/acme/acme-go", Ecosystem: "go"} + for release, want := range map[string]string{"73.0.0": "github.com/acme/acme-go/v73", "1.4.0": "github.com/acme/acme-go", "0.31.0": "github.com/acme/acme-go"} { + if got := f.At(release).installed(); got != want { + t.Errorf("%s: %s, want %s", release, got, want) + } + } +} + +// A release's notes on GitHub are read whole: any heading level starts a +// section, a code fence is skipped, and notes for another tag or none at +// all are never read as "no breaking changes". +func TestReleaseNotesAreReadWhole(t *testing.T) { + f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") + body := "## BREAKING CHANGES\\n\\n* `acme.old()` has been removed\\n\\n```\\n- `acme.example()` has been removed\\n```\\n\\n### Features\\n\\n* add `acme.new()`\\n" + _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "name": "v2.0.0", "body": "` + body + `"}`)) + if err != nil { + t.Fatal(err) + } + if len(fs) != 1 || fs[0].Dropped != "" || strings.Join(fs[0].Change.Symbols, ",") != "acme.old" { + t.Errorf("findings %+v", fs) + } + if f.Cite() != "https://github.com/acme/acme/releases/tag/v2.0.0" || f.URL() != "https://api.github.com/repos/acme/acme/releases/tags/v2.0.0" { + t.Errorf("cite %s, url %s", f.Cite(), f.URL()) + } + if _, _, err := f.Read([]byte(`{"tag_name": "v1.9.0", "body": "x"}`)); err == nil { + t.Error("another release's notes: want an error") + } + if _, _, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": ""}`)); !errors.Is(err, plugin.ErrNothingToRead) { + t.Errorf("no notes: %v, want plugin.ErrNothingToRead", err) + } +} diff --git a/plugins/changelog/classify.go b/plugins/changelog/classify.go index 3b50675..a1e24e8 100644 --- a/plugins/changelog/classify.go +++ b/plugins/changelog/classify.go @@ -22,8 +22,11 @@ const ( // SectionKind classifies a section title. func SectionKind(title string) Kind { t := strings.ToLower(title) + // "Major Changes" is a changesets changelog's section for what made the + // release a new major. breaking := strings.Contains(t, "removed") || strings.Contains(t, "removal") || - strings.Contains(t, "breaking") || strings.Contains(t, "incompatible") + strings.Contains(t, "breaking") || strings.Contains(t, "incompatible") || + strings.HasPrefix(t, "major change") deprecation := strings.Contains(t, "deprecat") switch { case breaking && deprecation: @@ -39,7 +42,26 @@ func SectionKind(title string) Kind { // A bullet in any section that starts with one of these is breaking: Keep a // Changelog has no "Breaking" section, so projects mark it inline under // "Changed" ("Breaking change: Removed `App.dark` reactive attribute"). -var breakingPrefix = regexp.MustCompile(`(?i)^\**(breaking( changes?)?|backwards?[- ]incompatible)\**\s*[:!-]\s*`) +// Stripe marks each breaking bullet with "⚠️", Neon with "**[BREAKING]**", +// conventional commits with "!" after the type ("remove!: ..."). +var breakingPrefix = regexp.MustCompile(`(?i)^(?:\**(?:breaking( changes?)?|backwards?[- ]incompatible)\**\s*[:!-]\s*|⚠️?\s*|\**\[breaking\]\**\s*|[a-z]+(?:\([^)]*\))?!:\s*)`) + +// What a bullet may start with that says nothing about the change, stripped +// before it's read: an area ("**client:**", "[datadog_monitor]", "Tracing - +// ", "Core: "), its issue or pull request ("[#1914](...)", "[[#51](...)]"), +// a changesets entry's commit and thanks ("abc1234: ", "[#12](...) +// [`abc1234`](...) Thanks [@me](...)! - "). +var noisePrefix = regexp.MustCompile("^(?:" + strings.Join([]string{ + `\*\*[\w ,./-]+:\*\*\s*`, + `\[[\w ,./-]+\]\s+`, + `\[\[#\d+\]\([^)]*\)\]\s*`, + `\[#\d+\]\([^)]*\)\s*`, + `\[` + "`" + `[0-9a-f]{7,40}` + "`" + `\]\([^)]*\)\s*`, + "`?[0-9a-f]{7,40}`?:?\\s+", + `Thanks \[@[^\]]+\]\([^)]*\)!\s*-\s*`, + `(?:[A-Z][\w/]*(?: [A-Z][\w/]*)*) - `, + `[A-Z][a-zA-Z]+: `, +}, "|") + ")") // Change is what one bullet says, when it says it plainly enough. type Change struct { @@ -62,27 +84,36 @@ var ( // Templates over a bullet's first sentence with every code span replaced by // §. Each says one thing plainly; a bullet matching none is dropped. const ( - noun = `(?:(?:reactive )?(?:module|method|function|class|attribute|property|constant|widget|exception|warning|classvar|alias)s?)` + noun = `(?:(?:reactive |read-only |optional )?(?:module|method|function|class|attribute|property|constant|widget|exception|warning|classvar|alias|type|field|enum|interface|struct|resource|data source|sub-resource|definition)(?:es|s)?)` list = `(§(?:(?:,? and |, )§)*)` ) var ( - removedActive = regexp.MustCompile(`(?i)^(?:removed|remove|dropped|drop) (?:the )?(?:deprecated )?(?:` + noun + ` )?` + list + - `(?: ` + noun + `)?(?: from (?:the )?(?:` + noun + ` )?(§)(?: ` + noun + `)?)?(?: \(now called (§)\))?$`) + removedActive = regexp.MustCompile(`(?i)^(?:removed|removes|remove|dropped|drops|drop) (?:the )?(?:previously )?(?:deprecated )?(?:` + noun + ` )?` + list + + `(?: ` + noun + `)?(?: (?:from|in|on|of) (?:the )?(?:` + noun + ` )?(§)(?: ` + noun + `)?)?(?: \(now called (§)\))?$`) removedPassive = regexp.MustCompile(`(?i)^(?:the )?(?:deprecated )?(?:` + noun + ` )?` + list + `(?: ` + noun + - `)? (?:has been |have been |was |were |is |are |is now |are now |now )?removed$`) - bare = regexp.MustCompile(`(?i)^(?:` + noun + ` )?` + list + `(?: ` + noun + `)?$`) - renamed = regexp.MustCompile(`(?i)^renamed (§)(?: ` + noun + `)? to (§)$`) - deprecActive = regexp.MustCompile(`(?i)^(?:deprecated|deprecate) (?:the )?(?:` + noun + ` )?` + list + `(?: ` + noun + `)?(?: (?:which|that) will be removed in .+| in favou?r of (?:the )?(§)(?: ` + noun + `)?)?$`) - deprecPassive = regexp.MustCompile(`(?i)^(?:the )?(?:` + noun + ` )?` + list + `(?: ` + noun + `)? (?:is|are) (?:now )?deprecated(?: in favou?r of (?:the )?(§)(?: ` + noun + `)?)?$`) + `)? (?:has been |have been |was |were |is |are |is now |are now |now )?removed(?: from (?:the )?(?:` + noun + ` )?(§)(?: ` + noun + `)?)?$`) + bare = regexp.MustCompile(`(?i)^(?:` + noun + ` )?` + list + `(?: ` + noun + `)?$`) + renamed = regexp.MustCompile(`(?i)^(?:renamed|renames|rename) (?:the )?(?:` + noun + ` )?(§)(?: ` + noun + `)? to (§)$`) + renamedPassive = regexp.MustCompile(`(?i)^(?:the )?(?:` + noun + ` )?(§)(?: ` + noun + `)? (?:has been|have been|was|were|is|is now) renamed to (?:the )?(§)$`) + deprecActive = regexp.MustCompile(`(?i)^(?:deprecated|deprecates|deprecate) (?:the )?(?:` + noun + ` )?` + list + `(?: ` + noun + `)?(?: (?:which|that) will be removed in .+| in favou?r of (?:the )?(§)(?: ` + noun + `)?)?$`) + deprecPassive = regexp.MustCompile(`(?i)^(?:the )?(?:` + noun + ` )?` + list + `(?: ` + noun + `)? (?:is|are) (?:now )?deprecated(?: in favou?r of (?:the )?(§)(?: ` + noun + `)?)?$`) ) // Classify reads one bullet of a section of kind k. ok is false for a bullet // that isn't breaking or a deprecation; why is set for one that is but // doesn't say plainly which names it changes (dropped, never guessed). func Classify(k Kind, text, module string) (c Change, ok bool, why string) { - if m := breakingPrefix.FindString(text); m != "" { - text, k = text[len(m):], KindBreaking + for { + if m := breakingPrefix.FindString(text); m != "" { + text, k = text[len(m):], KindBreaking + continue + } + if m := noisePrefix.FindString(text); m != "" { + text = text[len(m):] + continue + } + break } if k == KindNone { return Change{}, false, "" @@ -93,11 +124,14 @@ func Classify(k Kind, text, module string) (c Change, ok bool, why string) { if m := try(renamed); m != nil { return names(event.ChangeTypeBreaking, codes, "§", "", "", "", module, codes[1]) } + if m := try(renamedPassive); m != nil { + return names(event.ChangeTypeBreaking, codes, "§", "", "", "", module, codes[1]) + } if m := try(removedActive); m != nil { return names(event.ChangeTypeBreaking, codes, m[1], m[2], m[3], "", module, "") } if m := try(removedPassive); m != nil { - return names(event.ChangeTypeBreaking, codes, m[1], "", "", "", module, "") + return names(event.ChangeTypeBreaking, codes, m[1], m[2], "", "", module, "") } // Only names, no verb ("`Placeholder.reset_color_cycle`"): counts // under a Removed heading, where the heading is the verb. @@ -164,7 +198,8 @@ func names(ct event.ChangeType, codes []string, list, owner, newName, favour, mo repl = []string{renamedTo} } clean := func(s string) (string, bool) { - s = strings.TrimSuffix(strings.TrimSpace(s), "()") + // Ruby's and ioredis' "Class#method" is Class.method in code. + s = strings.ReplaceAll(strings.TrimSuffix(strings.TrimSpace(s), "()"), "#", ".") if module != "" { s = strings.TrimPrefix(s, module+".") } diff --git a/plugins/changelog/parse.go b/plugins/changelog/parse.go index 9739d27..5e6f6dd 100644 --- a/plugins/changelog/parse.go +++ b/plugins/changelog/parse.go @@ -24,9 +24,14 @@ type Bullet struct { } var ( - // Markdown: "## [1.2.0] - 2024-01-01", "## 1.2.0 (date)", "## v1.2.0". - mdRelease = regexp.MustCompile(`^##\s+\[?v?([0-9][^\]\s)]*)\]?`) + // Markdown: "## [1.2.0] - 2024-01-01", "## 1.2.0 (date)", "## v1.2.0", + // Stripe's "## 16.1.0 - date", Datadog's + // "## 2.67.0/2026-10-13", and semantic-release's "# [5.0.0](...)" for a + // major. + mdRelease = regexp.MustCompile(`^##?\s+(?:]*>\s*)?\[?v?([0-9][^\]\s)/]*)\]?`) mdSection = regexp.MustCompile(`^###\s+(.+?)\s*$`) + // A release's notes on their own use any level. + anyHeading = regexp.MustCompile(`^#{1,6}\s+(.+?)\s*$`) // "**Deprecations**:" on a line of its own (httpx's variant). boldSection = regexp.MustCompile(`^\*\*([^*]+)\*\*:?\s*$`) // RST: a title line, then an underline of one punctuation character at @@ -43,24 +48,46 @@ var ( // "-----"). Text before the first section title is not a section. A // changelog without the release is an error: the file moved or the release // isn't in it, and neither may read as "no breaking changes". -func ReleaseNotes(file []byte, release string) (heading string, sections []Section, err error) { +func ReleaseNotes(file []byte, release string) (string, []Section, error) { lines := strings.Split(strings.ReplaceAll(string(file), "\r\n", "\n"), "\n") heading, body, rst, err := releaseLines(lines, release) if err != nil { return "", nil, err } + return heading, sections(body, rst, mdSection), nil +} + +// NotesSections are the sections of one release's notes on their own (a +// GitHub release's body): every Markdown heading, whatever its level, starts +// one, and so does a bold line. +func NotesSections(body string) []Section { + return sections(strings.Split(strings.ReplaceAll(body, "\r\n", "\n"), "\n"), false, anyHeading) +} + +// sections splits a release's lines into titled sections of bullets: a +// Markdown heading (heading) or a reStructuredText title (rst) starts one. +func sections(body []string, rst bool, heading *regexp.Regexp) []Section { var out []Section var cur *Section + fenced := false for i := 0; i < len(body); i++ { l := body[i] + // A fenced code block is an example, never a title or a bullet. + if strings.HasPrefix(strings.TrimSpace(l), "```") { + fenced = !fenced + continue + } + if fenced { + continue + } title := "" switch { case rst && i+1 < len(body) && strings.TrimSpace(l) != "" && !bullet.MatchString(l) && rstUnderline.MatchString(strings.TrimSpace(body[i+1])) && len(strings.TrimSpace(body[i+1])) >= len(strings.TrimSpace(l)): title = strings.TrimSpace(l) i++ - case !rst && mdSection.MatchString(l): - title = mdSection.FindStringSubmatch(l)[1] + case !rst && heading.MatchString(l): + title = heading.FindStringSubmatch(l)[1] case boldSection.MatchString(strings.TrimSpace(l)): title = boldSection.FindStringSubmatch(strings.TrimSpace(l))[1] } @@ -90,18 +117,19 @@ func ReleaseNotes(file []byte, release string) (heading string, sections []Secti b.Raw += "\n" + l } } - return heading, out, nil + return out } // releaseLines are release's heading and the lines under it, up to the next // release's, and whether the file is reStructuredText. func releaseLines(lines []string, release string) (string, []string, bool, error) { - // Markdown first: a "## " heading naming the release. + // Markdown first: a "## " (or "# ") heading naming the release, up to + // the next one. for i, l := range lines { if m := mdRelease.FindStringSubmatch(l); m != nil && m[1] == release { end := len(lines) for j := i + 1; j < len(lines); j++ { - if strings.HasPrefix(lines[j], "## ") { + if strings.HasPrefix(lines[j], "## ") || strings.HasPrefix(lines[j], "# ") { end = j break } diff --git a/plugins/changelog/parse_test.go b/plugins/changelog/parse_test.go index 4017537..b3b5106 100644 --- a/plugins/changelog/parse_test.go +++ b/plugins/changelog/parse_test.go @@ -61,6 +61,19 @@ func TestOnlyAPlainSentenceNamesItsSymbols(t *testing.T) { {KindDeprecation, "Deprecated ``pkg.contrib.x`` module which will be removed in pkg v2.1.0 (#1)", "deprecation removed_symbol contrib.x"}, {KindMixed, "Removed `X`", "breaking removed_symbol X"}, {KindMixed, "Deprecated `Y`", "deprecation removed_symbol Y"}, + // The SDK changelogs' shapes: a mark that makes a bullet breaking, and + // an area, issue or commit read past. + {KindNone, "⚠️ [#1914](https://x.test/1914) Remove deprecated `StripeObject.request()` method", "breaking removed_symbol StripeObject.request"}, + {KindNone, "⚠️ Remove `RedirectUrl` from `LoginLinkCreateOptions`. The property was deprecated.", "breaking removed_symbol LoginLinkCreateOptions.RedirectUrl"}, + {KindNone, "**[BREAKING]** Removed the attribute `default_branch_protected` from the resource `neon_project`.", "breaking removed_symbol neon_project.default_branch_protected"}, + {KindNone, "feat(core)!: Remove `BaseClient` ([#17071](https://x.test/17071))", "breaking removed_symbol BaseClient"}, + {KindBreaking, "**ssl:** The `Host`, `Status`, and `ValidationMethod` types have been removed from `pkg.types.ssl`.", "breaking removed_symbol types.ssl.Host,types.ssl.Status,types.ssl.ValidationMethod"}, + {KindBreaking, "fc05013: Remove `Capture.Library` and `Exception.Library`. Set `$lib` instead.", "breaking removed_symbol Capture.Library,Exception.Library"}, + {KindBreaking, "`octokit.users.listEmails()` has been renamed to `octokit.users.listEmailsForAuthenticated()`", "breaking renamed_symbol octokit.users.listEmails>octokit.users.listEmailsForAuthenticated"}, + {KindBreaking, "`Redis#serverInfo` is removed. This field is never documented.", "breaking removed_symbol Redis.serverInfo"}, + {KindDeprecation, "Tracing - Deprecates `ddtrace.filters.FilterRequestsOnUrl`.", "deprecation removed_symbol ddtrace.filters.FilterRequestsOnUrl"}, + {SectionKind("Major Changes"), "Remove `X`", "breaking removed_symbol X"}, + {SectionKind("⚠ BREAKING CHANGES"), "**api:** add support for new API version 2026-10-21", "drop"}, // Not plain: dropped. {KindBreaking, "Drop support for Python 3.7. (#2813)", "drop"}, {KindBreaking, "Removed `limit_rules` from Stylesheet.apply", "drop"}, diff --git a/plugins/changelog/testdata/README.md b/plugins/changelog/testdata/README.md index a52d3ca..b8e5b4f 100644 --- a/plugins/changelog/testdata/README.md +++ b/plugins/changelog/testdata/README.md @@ -13,6 +13,7 @@ golden files under `golden/` are what the plugin stores from them | File | URL | Saved | License | Use | |---|---|---|---|---| +| `versions/stripe-go-tags.json`, `versions/octokit-rest-releases.json` | https://api.github.com/repos/stripe/stripe-go/tags, https://api.github.com/repos/octokit/rest.js/releases (shape only) | written for the test, 2026-11-20 | not saved copies: a few real tag names and releases in the shape of GitHub's API (a pre-release, a draft and a tag of another series among them) | for the version-listing test only (tags for an ecosystem with no registry lister, releases for release notes); no golden reads them | | `pypi-urllib3-excerpt.json` | https://pypi.org/pypi/urllib3/json (shape only) | written for the test, 2026-11-20 | not a saved copy: four releases in the shape of PyPI's JSON API (`releases` → files with `upload_time_iso_8601`, `yanked`), dates approximate, a pre-release among them | for the version-listing test only (ListVersions, consecutive pairs); no golden reads it | ## JSON changelogs diff --git a/plugins/changelog/testdata/versions/octokit-rest-releases.json b/plugins/changelog/testdata/versions/octokit-rest-releases.json new file mode 100644 index 0000000..4eab1fe --- /dev/null +++ b/plugins/changelog/testdata/versions/octokit-rest-releases.json @@ -0,0 +1,6 @@ +[ + {"tag_name": "v18.0.1-beta.1", "draft": false, "prerelease": true, "published_at": "2020-07-20T00:00:00Z", "html_url": "https://github.com/octokit/rest.js/releases/tag/v18.0.1-beta.1"}, + {"tag_name": "v18.0.0", "draft": false, "prerelease": false, "published_at": "2020-07-08T00:00:00Z", "html_url": "https://github.com/octokit/rest.js/releases/tag/v18.0.0"}, + {"tag_name": "v17.11.2", "draft": false, "prerelease": false, "published_at": "2020-06-25T00:00:00Z", "html_url": "https://github.com/octokit/rest.js/releases/tag/v17.11.2"}, + {"tag_name": "v19.0.0", "draft": true, "prerelease": false, "published_at": "0001-01-01T00:00:00Z", "html_url": ""} +] diff --git a/plugins/changelog/testdata/versions/stripe-go-tags.json b/plugins/changelog/testdata/versions/stripe-go-tags.json new file mode 100644 index 0000000..85bc087 --- /dev/null +++ b/plugins/changelog/testdata/versions/stripe-go-tags.json @@ -0,0 +1,7 @@ +[ + {"name": "v73.1.0-beta.1"}, + {"name": "v73.0.0"}, + {"name": "v72.122.0"}, + {"name": "wif-v0.1.0-alpha.1"}, + {"name": "v72.121.0"} +] diff --git a/plugins/changelog/versions_test.go b/plugins/changelog/versions_test.go index 809d4ca..123dec0 100644 --- a/plugins/changelog/versions_test.go +++ b/plugins/changelog/versions_test.go @@ -79,3 +79,32 @@ func TestAReleaseWithNoSectionIsNothingToRead(t *testing.T) { t.Errorf("err = %v, want plugin.ErrNothingToRead naming 2.0.1", err) } } + +// An ecosystem patch-it lists no registry for (Go here) lists the repo's +// TagPrefix + X.Y.Z tags; a source read from release notes lists the repo's +// published releases. Pre-releases, drafts and other tags are left out. +func TestReleasesFromTagsAndFromGitHubReleases(t *testing.T) { + env := kittest.Env(t, kittest.Pages{ + "https://api.github.com/repos/stripe/stripe-go/tags?per_page=100&page=1": "testdata/versions/stripe-go-tags.json", + "https://api.github.com/repos/octokit/rest.js/releases?per_page=100&page=1": "testdata/versions/octokit-rest-releases.json", + }) + for _, c := range []struct { + file File + want string + }{ + {File{API: "stripe/go", Ecosystem: "go", Repo: "stripe/stripe-go", TagPrefix: "v", Path: "CHANGELOG.md"}, "72.121.0@v72.121.0 72.122.0@v72.122.0 73.0.0@v73.0.0"}, + {File{API: "github/octokit-rest", Ecosystem: "npm", Repo: "octokit/rest.js", TagPrefix: "v", Notes: true}, "17.11.2@v17.11.2 18.0.0@v18.0.0"}, + } { + vs, err := Plugin{File: c.file}.ListVersions(context.Background(), env) + if err != nil { + t.Fatal(err) + } + var ids []string + for _, v := range vs { + ids = append(ids, v.ID+"@"+v.Ref) + } + if got := strings.Join(ids, " "); got != c.want { + t.Errorf("%s: %s, want %s", c.file.API, got, c.want) + } + } +} From 894fdd2ae3c490b0d7e57eee2598c7bcd5e68e5a Mon Sep 17 00:00:00 2001 From: adssib <75389300+adssib@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:15:25 -0500 Subject: [PATCH 2/3] changelog: follow renames to their end; names alone only under removed A rename whose new name the same release renames again or removes now points to where the chain ends (or to nothing). A bullet of names alone is a removal only under a Removed heading, and a change word ("Deprecated:") is never read past as an area. Co-Authored-By: Claude Opus 5.5 Signed-off-by: adssib <75389300+adssib@users.noreply.github.com> --- plugins/changelog/changelog.go | 39 ++++++++++++++++++++++++++++- plugins/changelog/changelog_test.go | 22 ++++++++++++++++ plugins/changelog/classify.go | 18 ++++++++++--- plugins/changelog/parse_test.go | 8 +++--- 4 files changed, 80 insertions(+), 7 deletions(-) diff --git a/plugins/changelog/changelog.go b/plugins/changelog/changelog.go index 0d4d44f..a0be1e1 100644 --- a/plugins/changelog/changelog.go +++ b/plugins/changelog/changelog.go @@ -190,7 +190,44 @@ func (f File) Read(page []byte) (heading string, out []Finding, err error) { out = append(out, Finding{Change: c, Section: s.Title, Bullet: b, Dropped: why}) } } - return heading, out, nil + return heading, chained(out), nil +} + +// chained follows each rename through the release's other renames and +// removals, so a replacement is the name the release ends with: "A renamed +// to B" and "B renamed to C" make A's replacement C; a chain that ends in a +// removal (or loops) leaves A removed, with no replacement to move to. +func chained(fs []Finding) []Finding { + renamed, removed := map[string]string{}, map[string]bool{} + for _, f := range fs { + if f.Dropped != "" || f.Change.ChangeType != event.ChangeTypeBreaking { + continue + } + for _, sym := range f.Change.Symbols { + if f.Change.Replacement != "" { + renamed[sym] = f.Change.Replacement + } else { + removed[sym] = true + } + } + } + for i, f := range fs { + r := f.Change.Replacement + if f.Dropped != "" || r == "" { + continue + } + seen := map[string]bool{} + for next, ok := renamed[r]; ok && !seen[r]; next, ok = renamed[r] { + seen[r] = true + r = next + } + if removed[r] || seen[r] { + fs[i].Change.Replacement, fs[i].Change.Change = "", event.PackageRemovedSymbol + continue + } + fs[i].Change.Replacement = r + } + return fs } // notes are the sections of a GitHub release's body (the API's JSON for one diff --git a/plugins/changelog/changelog_test.go b/plugins/changelog/changelog_test.go index 86114fa..8b08183 100644 --- a/plugins/changelog/changelog_test.go +++ b/plugins/changelog/changelog_test.go @@ -130,3 +130,25 @@ func TestReleaseNotesAreReadWhole(t *testing.T) { t.Errorf("no notes: %v, want plugin.ErrNothingToRead", err) } } + +// A rename whose new name the same release renames again or removes points +// to where the chain ends: never to a name the release took away. +func TestRenamesAreFollowedToTheirEnd(t *testing.T) { + f := File{Package: "acme", Repo: "acme/acme", TagPrefix: "v", Notes: true}.At("2.0.0") + body := "## BREAKING CHANGES\\n\\n" + + "* `acme.a()` has been renamed to `acme.b()`\\n* `acme.b()` has been renamed to `acme.c()`\\n" + + "* `acme.x()` has been renamed to `acme.y()`\\n* `acme.y()` has been removed\\n" + + "* `acme.p()` has been renamed to `acme.q()`\\n* `acme.q()` has been renamed to `acme.p()`\\n" + _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": "` + body + `"}`)) + if err != nil { + t.Fatal(err) + } + var got []string + for _, f := range fs { + got = append(got, strings.Join(f.Change.Symbols, ",")+">"+f.Change.Replacement) + } + want := "acme.a>acme.c acme.b>acme.c acme.x> acme.y> acme.p> acme.q>" + if strings.Join(got, " ") != want { + t.Errorf("got %s\nwant %s", strings.Join(got, " "), want) + } +} diff --git a/plugins/changelog/classify.go b/plugins/changelog/classify.go index a1e24e8..cd79901 100644 --- a/plugins/changelog/classify.go +++ b/plugins/changelog/classify.go @@ -14,7 +14,8 @@ type Kind int const ( KindNone Kind = iota - KindBreaking // Removed, Breaking changes, Backwards incompatible changes + KindBreaking // Breaking changes, Backwards incompatible changes, Major Changes + KindRemoved // Removed: breaking, and a bullet of names alone is a removal KindDeprecation // Deprecated, Deprecations KindMixed // "Deprecations and Removals": the bullet's verb decides ) @@ -31,6 +32,8 @@ func SectionKind(title string) Kind { switch { case breaking && deprecation: return KindMixed + case breaking && !strings.Contains(t, "breaking") && (strings.Contains(t, "removed") || strings.Contains(t, "removal")): + return KindRemoved case breaking: return KindBreaking case deprecation: @@ -63,6 +66,8 @@ var noisePrefix = regexp.MustCompile("^(?:" + strings.Join([]string{ `[A-Z][a-zA-Z]+: `, }, "|") + ")") +var changeWord = regexp.MustCompile(`(?i)^(added|changed|deprecated|fixed|security|updated|improved)\b`) + // Change is what one bullet says, when it says it plainly enough. type Change struct { ChangeType event.ChangeType @@ -109,7 +114,9 @@ func Classify(k Kind, text, module string) (c Change, ok bool, why string) { text, k = text[len(m):], KindBreaking continue } - if m := noisePrefix.FindString(text); m != "" { + // "Deprecated: `X`" or "Added: `X`" says what the change is: its + // word is not an area to read past. + if m := noisePrefix.FindString(text); m != "" && !changeWord.MatchString(m) { text = text[len(m):] continue } @@ -118,8 +125,13 @@ func Classify(k Kind, text, module string) (c Change, ok bool, why string) { if k == KindNone { return Change{}, false, "" } + removedHeading := false sentence, codes := template(text) try := func(re *regexp.Regexp) []string { return re.FindStringSubmatch(sentence) } + if k == KindRemoved { + k = KindBreaking + removedHeading = true + } if k != KindDeprecation { if m := try(renamed); m != nil { return names(event.ChangeTypeBreaking, codes, "§", "", "", "", module, codes[1]) @@ -135,7 +147,7 @@ func Classify(k Kind, text, module string) (c Change, ok bool, why string) { } // Only names, no verb ("`Placeholder.reset_color_cycle`"): counts // under a Removed heading, where the heading is the verb. - if m := try(bare); m != nil && k == KindBreaking { + if m := try(bare); m != nil && removedHeading { return names(event.ChangeTypeBreaking, codes, m[1], "", "", "", module, "") } } diff --git a/plugins/changelog/parse_test.go b/plugins/changelog/parse_test.go index b3b5106..e6a8bde 100644 --- a/plugins/changelog/parse_test.go +++ b/plugins/changelog/parse_test.go @@ -49,8 +49,10 @@ func TestOnlyAPlainSentenceNamesItsSymbols(t *testing.T) { want string // "ct change symbols>replacement", "" = not breaking/deprecation, "drop" }{ {KindBreaking, "Removed `App.dark` reactive attribute https://x.test/pull/1", "breaking removed_symbol App.dark"}, - {KindBreaking, "`Placeholder.reset_color_cycle`", "breaking removed_symbol Placeholder.reset_color_cycle"}, - {KindBreaking, "Property `Widget.focusable_children` https://x.test/1", "breaking removed_symbol Widget.focusable_children"}, + {KindRemoved, "`Placeholder.reset_color_cycle`", "breaking removed_symbol Placeholder.reset_color_cycle"}, + {KindBreaking, "`Placeholder.reset_color_cycle`", "drop"}, // names alone count only under Removed + {KindRemoved, "Deprecated: `X`", "drop"}, // a change word is not an area + {KindRemoved, "Property `Widget.focusable_children` https://x.test/1", "breaking removed_symbol Widget.focusable_children"}, {KindBreaking, "Removed `Widget.reset_focus` (now called `Widget.blur`) https://x.test/1", "breaking renamed_symbol Widget.reset_focus>Widget.blur"}, {KindBreaking, "Removed the ``_prepare_conn`` method from ``HTTPConnectionPool``. Previously…", "breaking removed_symbol HTTPConnectionPool._prepare_conn"}, {KindBreaking, "Removed ``pkg.a`` and ``pkg.b()`` (`#1 `__).", "breaking removed_symbol a,b"}, @@ -105,7 +107,7 @@ func TestOnlyAPlainSentenceNamesItsSymbols(t *testing.T) { } } if SectionKind("Deprecations and Removals") != KindMixed || SectionKind("Backwards incompatible changes") != KindBreaking || - SectionKind("Removed") != KindBreaking || SectionKind("Changed") != KindNone { + SectionKind("Removed") != KindRemoved || SectionKind("Changed") != KindNone { t.Error("section kinds") } } From 080138075f64d1b78048ec550f97adb89babd1fd Mon Sep 17 00:00:00 2001 From: adssib <75389300+adssib@users.noreply.github.com> Date: Fri, 20 Nov 2026 21:20:24 -0500 Subject: [PATCH 3/3] changelog: a deprecation's replacement isn't followed as a rename Co-Authored-By: Claude Opus 5.5 Signed-off-by: adssib <75389300+adssib@users.noreply.github.com> --- plugins/changelog/changelog.go | 4 +++- plugins/changelog/changelog_test.go | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/changelog/changelog.go b/plugins/changelog/changelog.go index a0be1e1..809f0b8 100644 --- a/plugins/changelog/changelog.go +++ b/plugins/changelog/changelog.go @@ -213,7 +213,9 @@ func chained(fs []Finding) []Finding { } for i, f := range fs { r := f.Change.Replacement - if f.Dropped != "" || r == "" { + // Only a breaking rename is followed: a deprecation in favor of a + // name stays a deprecation, whatever happens to that name. + if f.Dropped != "" || r == "" || f.Change.ChangeType != event.ChangeTypeBreaking { continue } seen := map[string]bool{} diff --git a/plugins/changelog/changelog_test.go b/plugins/changelog/changelog_test.go index 8b08183..a89238d 100644 --- a/plugins/changelog/changelog_test.go +++ b/plugins/changelog/changelog_test.go @@ -138,7 +138,8 @@ func TestRenamesAreFollowedToTheirEnd(t *testing.T) { body := "## BREAKING CHANGES\\n\\n" + "* `acme.a()` has been renamed to `acme.b()`\\n* `acme.b()` has been renamed to `acme.c()`\\n" + "* `acme.x()` has been renamed to `acme.y()`\\n* `acme.y()` has been removed\\n" + - "* `acme.p()` has been renamed to `acme.q()`\\n* `acme.q()` has been renamed to `acme.p()`\\n" + "* `acme.p()` has been renamed to `acme.q()`\\n* `acme.q()` has been renamed to `acme.p()`\\n" + + "## Deprecations\\n\\n* Deprecated `acme.d` in favor of `acme.y`\\n" _, fs, err := f.Read([]byte(`{"tag_name": "v2.0.0", "body": "` + body + `"}`)) if err != nil { t.Fatal(err) @@ -147,7 +148,7 @@ func TestRenamesAreFollowedToTheirEnd(t *testing.T) { for _, f := range fs { got = append(got, strings.Join(f.Change.Symbols, ",")+">"+f.Change.Replacement) } - want := "acme.a>acme.c acme.b>acme.c acme.x> acme.y> acme.p> acme.q>" + want := "acme.a>acme.c acme.b>acme.c acme.x> acme.y> acme.p> acme.q> acme.d>acme.y" if strings.Join(got, " ") != want { t.Errorf("got %s\nwant %s", strings.Join(got, " "), want) }