also looking at this
fix(rules): apply a rule's autoMigrate, closing the rule-effects family
#1423
2 files
+90
-1
| @@ -3,6 +3,7 @@ import type { BuddyConfig, PackageUpdate } from '../types' | ||
| 3 | 3 | import type { Logger } from '../utils/logger' |
| 4 | 4 | import type { UpgradeResult } from './migrate' |
| 5 | 5 | import { stripManifest } from '../pr/pr-manifest' |
| 6 | import { groupsToRules, resolveRuleEffects } from '../rules/engine' | |
| 6 | 7 | import { getDefaultLogger } from '../utils/logger' |
| 7 | 8 | import { attemptMajorUpgrade } from './migrate' |
| 8 | 9 | import { collectSpanNotes, describeSpanGaps } from './span' |
| @@ -92,6 +93,10 @@ export async function analyzeGroupMajors(options: GroupUpgradeOptions): Promise< | ||
| 92 | 93 | const results: GroupUpgradeOutcome['results'] = [] |
| 93 | 94 | const skipped: GroupUpgradeOutcome['skipped'] = [] |
| 94 | 95 | |
| 96 | // `autoMigrate` on a package rule was resolved into the effects and read by | |
| 97 | // nobody, so only the repository-wide setting ever reached the migration. | |
| 98 | const rules = [...groupsToRules(options.config.packages?.groups), ...(options.config.packages?.rules ?? [])] | |
| 99 | ||
| 95 | 100 | for (const update of majors) { |
| 96 | 101 | if (!matchesGlobs(update.name, settings.packages)) { |
| 97 | 102 | skipped.push({ name: update.name, reason: 'not matched by ai.majorUpgrades.packages' }) |
| @@ -103,6 +108,14 @@ export async function analyzeGroupMajors(options: GroupUpgradeOptions): Promise< | ||
| 103 | 108 | const span = collectSpanNotes(releases, update.currentVersion, update.newVersion) |
| 104 | 109 | const gaps = describeSpanGaps(span) |
| 105 | 110 | |
| 111 | // Resolved per package rather than per group: this loop already runs | |
| 112 | // once per major, and the documented reading — "one package opting in is | |
| 113 | // enough, since migrating what can be migrated leaves everything else | |
| 114 | // exactly as it would have been" — is an argument for deciding each on | |
| 115 | // its own rather than letting one opt-in carry the rest. | |
| 116 | const ruled = rules.length > 0 ? resolveRuleEffects(update, rules).autoMigrate : undefined | |
| 117 | const autoMigrate = ruled ?? settings.autoMigrate | |
| 118 | ||
| 106 | 119 | const result = await attemptMajorUpgrade({ |
| 107 | 120 | update, |
| 108 | 121 | releaseNotes: span.notes, |
| @@ -110,7 +123,7 @@ export async function analyzeGroupMajors(options: GroupUpgradeOptions): Promise< | ||
| 110 | 123 | workspace: options.workspace, |
| 111 | 124 | baseBranch: options.baseBranch, |
| 112 | 125 | ai: options.ai, |
| 113 | ...(settings.autoMigrate !== undefined ? { autoMigrate: settings.autoMigrate } : {}), | |
| 126 | ...(autoMigrate !== undefined ? { autoMigrate } : {}), | |
| 114 | 127 | ...(settings.draftBelowConfidence ? { draftBelowConfidence: settings.draftBelowConfidence } : {}), |
| 115 | 128 | logger, |
| 116 | 129 | }) |