Skip to content

fix: derive valid commit titles for message-only updates#197

Merged
joshjohanning merged 3 commits into
joshjohanning:mainfrom
Wuodan:upstream-PR/fix-derive-valid-commit-titles-for-message-only-updates
May 5, 2026
Merged

fix: derive valid commit titles for message-only updates#197
joshjohanning merged 3 commits into
joshjohanning:mainfrom
Wuodan:upstream-PR/fix-derive-valid-commit-titles-for-message-only-updates

Conversation

@Wuodan

@Wuodan Wuodan commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

When only a squash or merge commit message is configured, the action used to reuse the current repository title setting. That could produce invalid GitHub API combinations such as COMMIT_OR_PR_TITLE + BLANK for squash commits or MERGE_MESSAGE + BLANK for merge commits.

Choose a compatible title for the requested message instead, while preserving the current title only when that combination remains valid.

Add focused unit coverage for squash-only and merge-only message updates.


Example of error message with invalid GitHub API combination:

Warning: ❌ Failed to update bulk-repo-settings-sync-test-Wuodan/it-commit-message-message-only-a: Validation Failed: {"message":"Sorry, invalid setting combination. The following are valid combinations for the squash commit title and message: PR_TITLE and PR_BODY, PR_TITLE and BLANK, PR_TITLE and COMMIT_MESSAGES, COMMIT_OR_PR_TITLE and COMMIT_MESSAGES. (invalid_squash_commit_setting_combo)","resource":"Repository","field":"merge_commit_allowed","code":"invalid"} - https://docs.github.com/rest/repos/repos#update-a-repository

When only a squash or merge commit message is configured, the action used to reuse the current repository title setting. That could produce invalid GitHub API combinations such as COMMIT_OR_PR_TITLE + BLANK for squash commits or MERGE_MESSAGE + BLANK for merge commits.

Choose a compatible title for the requested message instead, while preserving the current title only when that combination remains valid.

Add focused unit coverage for squash-only and merge-only message updates.
@Wuodan Wuodan force-pushed the upstream-PR/fix-derive-valid-commit-titles-for-message-only-updates branch from a359a00 to 3b908de Compare April 28, 2026 02:54
@joshjohanning joshjohanning requested a review from Copilot May 5, 2026 18:09

Copilot AI 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.

Pull request overview

This PR fixes an edge case in updateRepositorySettings() where updating only the squash/merge commit message could reuse an incompatible existing title, leading to GitHub REST API validation failures. It adds helpers to derive a compatible title when only a message is provided, and adds unit tests covering “message-only” updates for squash and merge commits.

Changes:

  • Derive a valid squash/merge commit title when only the corresponding commit message is being updated.
  • Treat both null and undefined as “not provided” for settings inputs (switching checks to != null).
  • Add focused Jest tests for squash-only and merge-only message updates.
Show a summary per file
File Description
src/index.js Adds title-derivation helpers and updates null/undefined handling for settings application.
__tests__/index.test.js Adds unit coverage for squash-only and merge-only commit message update scenarios.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/index.js
Comment thread src/index.js
@joshjohanning joshjohanning merged commit 783c94c into joshjohanning:main May 5, 2026
1 check passed
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

📦 Draft Release Created

A draft release v2.9.4 has been created for this PR.

🔗 View Draft Release

Next Steps

  • Review the release notes
  • Publish the release to make it permanent

This is an automated reminder from the publish-github-action workflow.

joshjohanning added a commit to Wuodan/bulk-github-repo-settings-sync-action that referenced this pull request May 6, 2026
Integrate getValidSquashMergeCommitTitle/getValidMergeCommitTitle from
PR joshjohanning#197 into the REPOSITORY_SETTING_FIELDS descriptor table via
deriveCompanion function references. Also adopt != null checks from
main for consistency.
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.

3 participants