Skip to content

Never bump the version on a PR edit - #1058

Merged
boomzero merged 2 commits into
devfrom
updateversion-edited-no-bump
Oct 6, 2026
Merged

boomzero merged 2 commits into
devfrom
updateversion-edited-no-bump

Conversation

@boomzero

@boomzero boomzero commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What does this PR aim to accomplish?:

Stop PR edits from bumping the version. UpdateVersion also runs on edited events, and AI reviewers (cubic, Sourcery) rewrite PR descriptions under the author's account, so the !endsWith(github.actor, '[bot]') guard doesn't stop them. On #1057 one of these edits turned the manual 4.0.0 into 4.0.1 minutes after the PR was opened. The same path likely explains why 3.0.0 exists only as a prerelease (recorded under #906, like 2.7.4), so the first stable 3.x release was 3.1.0.

How does this PR accomplish the above?:

Update/UpdateVersion.js: on an edited event, the script now continues only if this PR already owns the latest version entry. In that case it refreshes the title, notes and time as before. Otherwise it exits without running npm version patch. Opened and synchronize runs are unchanged. This also stops an edit from bumping again after dev has been merged into a PR whose entry is no longer the latest.

Dry runs against current dev, with gh stubbed and a local remote:

  1. edited, PR doesn't own the latest entry (the Release as 4.0.0: the rating redesign is a breaking change #1057 case): skipped, still 4.0.0.
  2. edited, PR owns the latest entry: only "Update time and description of 4.0.0".
  3. synchronize, new PR: normal bump to 4.0.1 (prerelease).

This PR doesn't touch XMOJ.user.js, so it causes no version bump.


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributor's guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented on my proposed changes within the code.
  3. I have tested my changes.
  4. I am willing to help maintain this change if there are issues with it later.
  5. It is compatible with the GNU General Public License v3.0
  6. I have squashed any insignificant commits. (git rebase)
  7. I have checked that another pull request for this purpose does not exist.
  8. I have considered and confirmed that this submission will be valuable to others.
  9. I accept that this submission may not be used, and the pull request can be closed at the will of the maintainer.
  10. I give this submission freely and claim no ownership to its content.
  11. I have verified that my changes work correctly in both the new UI and the old/classic UI.

  • I have read the above and my PR is ready for review. Check this box to confirm

🤖 Generated with Claude Code

https://claude.ai/code/session_01E5dr7XTsCeoamqLSiT9rLp

Summary by Sourcery

Prevent edited pull requests from creating unintended version bumps while preserving normal version updates for newly opened or synchronized pull requests.

Bug Fixes:

  • Prevent version bumps when pull requests are edited, including edits made by automated reviewers acting under the author’s account.

Enhancements:

  • Allow edits to refresh metadata only when the pull request owns the latest version entry and the package and userscript versions are synchronized.

Summary by cubic

Stops Update/UpdateVersion.js from bumping the version when a PR is edited. AI reviewers (cubic, Sourcery) rewrite PR descriptions under the author's account, so the [bot] actor guard didn't stop them — on #1057 an edit turned the manual 4.0.0 into 4.0.1 minutes after the PR was opened.

On edited events the script now only refreshes this PR's own latest version entry and exits without running npm version patch otherwise; it also skips the metadata refresh when package.json and XMOJ.user.js are out of sync. opened and synchronize runs are unchanged. This also stops an edit from bumping after dev has been merged into a PR whose entry is no longer the latest.

Written for commit 6b1612c. Summary will update on new commits.

Review in cubic

UpdateVersion also runs on edited events, and AI reviewers (cubic,
Sourcery) edit PR descriptions on the author's behalf, so the [bot]
actor guard does not catch them. On #1057 such an edit bumped the
manual 4.0.0 to 4.0.1 minutes after the PR was opened; the same path
explains the prerelease-only 3.0.0. An edit now only refreshes this
PR's own latest entry and otherwise exits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5dr7XTsCeoamqLSiT9rLp
@sourcery-ai

sourcery-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Sorry @boomzero, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 10 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T05:18:59.405418Z a40fcf0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hendragon-bot hendragon-bot Bot added the update-script Related to our update infrastructure! label Oct 6, 2026
@sourcery-ai

sourcery-ai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The version updater now treats PR edits as metadata-only operations for the PR that owns the latest version entry, and skips them otherwise, preventing AI or author-driven description edits from incrementing the project version.

Flow diagram for PR event version update behavior

flowchart TD
    A[PR event] --> B{eventAction is edited?}
    B -- No --> C[Existing opened or synchronize logic]
    B -- Yes --> D{CurrentPR owns latest version entry?}
    D -- No --> E[Exit without npm version patch]
    D -- Yes --> F[Refresh title notes and time]
    C --> G[Normal version update behavior]
Loading

File-Level Changes

Change Details Files
Prevent edited pull requests from creating unintended version bumps while preserving metadata refreshes for the current release entry.
  • Add an early exit for edited events when the PR is not the latest version entry or the version state is inconsistent.
  • Retain the existing title, release notes, and timestamp refresh when the edited PR owns the latest entry.
  • Leave opened and synchronize version-bump behavior unchanged.
Update/UpdateVersion.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: a40fcf0
Status: ✅  Deploy successful!
Preview URL: https://7f71563a.xmoj-script-dev-channel.pages.dev
Branch Preview URL: https://updateversion-edited-no-bump.xmoj-script-dev-channel.pages.dev

View logs

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread Update/UpdateVersion.js Outdated
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Signed-off-by: Zhu Chenrui <boomzero_zcr@outlook.com>
@pull-request-size pull-request-size Bot added size/S and removed size/XS labels Oct 6, 2026
@boomzero
boomzero merged commit e486b31 into dev Oct 6, 2026
7 of 8 checks passed
@boomzero
boomzero deleted the updateversion-edited-no-bump branch October 6, 2026 06:32

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S update-script Related to our update infrastructure!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant