Never bump the version on a PR edit

Merged
BO
2mo ago
+12-0

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 #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.