Skip to content

fix: detect changes to the root package in single-package repos#125

Merged
theoephraim merged 2 commits into
mainfrom
claude/vibrant-khorana-610b5f
Jun 18, 2026
Merged

fix: detect changes to the root package in single-package repos#125
theoephraim merged 2 commits into
mainfrom
claude/vibrant-khorana-610b5f

Conversation

@theoephraim

@theoephraim theoephraim commented Jun 18, 2026

Copy link
Copy Markdown
Member

Problem

In a single-package (non-monorepo) repo, bumpy ci check always reported "No managed packages have changed — no bump files needed." and never posted a PR comment — even when source files clearly changed.

Reported via a fresh setup in dmno-dev/fledgling (failing run). The repo was not misconfigured.

Root cause

Changed files were matched against the package directory like so:

const pkgRelDir = relative(rootDir, pkg.dir);
if (file.startsWith(pkgRelDir + '/')) { ... }

For the root package of a single-package repo, pkg.dir === rootDir, so pkgRelDir === '' and the test becomes file.startsWith('/')always false for git's relative paths (src/cli.ts, etc.). The root package therefore never matched any changed file.

In monorepos every package lives under packages/<name>/, so pkgRelDir is non-empty and the bug was masked.

This same pattern appeared in two places:

  • findChangedPackages in check.ts — used by check and ci check
  • mapFilesToPackages in generate.ts — used by generate to attribute commits to packages

So generate was also failing to attribute any commit to the root package in single-package repos.

Fix

Treat the root package (empty relative dir) as owning every changed file. In findChangedPackages, changedFilePatterns is still honored:

const relToPackage =
  pkgRelDir === ''
    ? file
    : file.startsWith(pkgRelDir + '/')
      ? file.slice(pkgRelDir.length + 1)
      : null;
if (relToPackage !== null && matchers.get(name)!(relToPackage)) {
  changed.add(name);
}

Tests

  • findChangedPackages: root-package detection, changedFilePatterns honoring, monorepo directory scoping (regression).
  • mapFilesToPackages: root-package detection + monorepo scoping (exported the helper to test it).

Full suite: 314 pass / 0 fail. Lint, fmt, and typecheck clean.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/bumpy 1.14.0 → 1.14.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

findChangedPackages matched changed files against pkgRelDir + '/', but the
root package has an empty relative dir, making the check file.startsWith('/')
which never matches git's relative paths. ci check therefore always reported
'No managed packages have changed' in non-monorepo repos. The root package now
treats every changed file as its own (still honoring changedFilePatterns).
mapFilesToPackages had the same empty-pkgRelDir bug as findChangedPackages:
file.startsWith('/') never matches, so 'bumpy generate' never attributed
commits to the root package in single-package repos. Export it and cover both
single-package and monorepo cases with a test.
@theoephraim theoephraim force-pushed the claude/vibrant-khorana-610b5f branch from 90b6442 to 4999ea4 Compare June 18, 2026 20:55
@theoephraim theoephraim merged commit f8a7d92 into main Jun 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant