Skip to content

fix: only set root config version and commit if migrations ran#2513

Open
jackw wants to merge 4 commits intomainfrom
jackw/update-prevent-config-commit
Open

fix: only set root config version and commit if migrations ran#2513
jackw wants to merge 4 commits intomainfrom
jackw/update-prevent-config-commit

Conversation

@jackw
Copy link
Collaborator

@jackw jackw commented Mar 5, 2026

What this PR does / why we need it:

Currently if create-plugin update doesn't run any migrations it still updates the version in the cprc.json file. This creates unnecessary noise both locally and if update runs via CI. This PR addresses this by only updating the cprc.json file if any migrations ran.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/create-plugin@7.0.4-canary.2513.22728705812.0
# or 
yarn add @grafana/create-plugin@7.0.4-canary.2513.22728705812.0

Copilot AI review requested due to automatic review settings March 5, 2026 13:17
@jackw jackw requested a review from a team as a code owner March 5, 2026 13:17
@jackw jackw requested review from hugohaggmark and joshhunt March 5, 2026 13:17
@jackw jackw self-assigned this Mar 5, 2026
@jackw jackw added patch Increment the patch version when merged release Create a release when this pr is merged labels Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new patch release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@jackw jackw moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team Mar 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the create-plugin migration runner to avoid writing/committing the root .config/.cprc.json version when there are no migrations to execute, reducing no-op diffs and CI noise during create-plugin update.

Changes:

  • Guard .config/.cprc.json version updates behind migrations.length > 0.
  • Skip the version-update git commit when there are no migrations to run.

Comment on lines +46 to 53
// Only set the version in the config file if there were migrations to run.
if (migrations.length > 0) {
setRootConfig({ version: CURRENT_APP_VERSION });

if (options.commitEachMigration) {
await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`);
if (options.commitEachMigration) {
await gitCommitNoVerify(`chore: update .config/.cprc.json to version ${CURRENT_APP_VERSION}.`);
}
}
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new conditional introduces an untested behavior change: when migrations.length === 0, the root config version is no longer updated and the version-update commit is skipped. There are existing unit tests for runMigrations in this package; please add coverage for the empty-migrations case (including with commitEachMigration: true) to lock in the intended behavior.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +31 to 33
const migrationListBody =
migrationList.length > 0 ? output.bulletList(migrationList) : ['No migrations to run. Exiting.'];

Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message says "No migrations to run. Exiting." but runMigrations doesn’t actually early-return at that point (it just finishes naturally). Consider either returning immediately when migrations.length === 0 or changing the message to avoid implying an explicit exit, so future logic added after the loop won’t be misleading.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged release Create a release when this pr is merged

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

4 participants