Skip to content

refactor: repository settings sync internals#186

Merged
joshjohanning merged 6 commits into
joshjohanning:mainfrom
Wuodan:upstream-PR/refactor-repository-settings-sync-internals
May 6, 2026
Merged

refactor: repository settings sync internals#186
joshjohanning merged 6 commits into
joshjohanning:mainfrom
Wuodan:upstream-PR/refactor-repository-settings-sync-internals

Conversation

@Wuodan

@Wuodan Wuodan commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

This refactor reduces repetition in the repository settings sync path without changing its behavior.

The previous implementation repeated the same boolean toggle flow across immutable releases and several security settings, and it also duplicated the repository settings diff/update logic field by field.
With a growing number of features this made the code harder to review, extend, and keep consistent.

Changes in this commit:

  • introduce shared helpers for boolean endpoint and security_and_analysis toggles
  • pass shared per-repository context through a small ctx object instead of threading the same parameters repeatedly
  • replace the repeated repository settings diff/update chain with a descriptor table and loop
  • keep the existing result structure and warnings behavior intact

When implementing the feature for PR #185 I noticed how this just added another large block for a boolean feature.
So I thought about extracting such blocks to shared helpers to reduce repeated complexity.
While the reduction on line count is not as large as I hoped for, I still think such a capsulation should be considered.


With upcoming PR #169 we will likely see conflicts. I am willing to refactor this once PR #169 is merged.

This PR includes commits from other PRs:

@joshjohanning

joshjohanning commented Apr 23, 2026

Copy link
Copy Markdown
Owner

With upcoming PR #169 we will likely see conflicts. I am willing to refactor this once PR #169 is merged.

@Wuodan - all you 🙌

Love the concept here! A bit of a refactor but seems more sustainable / repeatable long term.

Edit:

Noting I will be out next week so no rush 🌴

This refactor reduces repetition in the repository settings sync path without changing its behavior.

The previous implementation repeated the same boolean toggle flow across immutable releases and several security settings, and it also duplicated the repository settings diff/update logic field by field.
With a growing number of features this made the code harder to review, extend, and keep consistent.

Changes in this commit:
- introduce shared helpers for boolean endpoint and security_and_analysis toggles
- pass shared per-repository context through a small ctx object instead of threading the same parameters repeatedly
- replace the repeated repository settings diff/update chain with a descriptor table and loop
- keep the existing result structure and warnings behavior intact
@Wuodan Wuodan force-pushed the upstream-PR/refactor-repository-settings-sync-internals branch from e2abe72 to c58ad70 Compare April 27, 2026 23:12
Wuodan added 2 commits April 28, 2026 04:54
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 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Refactor was done, this PR no longer is a draft and is ready for review and potential merge.

Edit:

@joshjohanning I start a new job on Monday so will be busy for quite some time 👷‍♂️

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 refactors the repository settings sync logic in src/index.js to reduce repeated boolean-toggle and settings-diff/update code paths while aiming to preserve existing behavior and result shaping.

Changes:

  • Added shared helpers for boolean feature toggle flows, including endpoint-backed toggles and security_and_analysis toggles.
  • Introduced a small per-repo ctx object to avoid repeatedly threading the same parameters through toggle handlers.
  • Replaced the repeated repository settings diff/update logic with a REPOSITORY_SETTING_FIELDS descriptor table and a single loop.
Show a summary per file
File Description
src/index.js Refactors boolean feature toggles and repository settings diff/update logic into shared helpers and descriptor-driven loops.

Copilot's findings

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

Comment thread src/index.js Outdated
joshjohanning and others added 3 commits May 5, 2026 20:10
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.
Resolve conflicts with the valid commit title fix and address CCR JSDoc feedback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshjohanning

joshjohanning commented May 6, 2026

Copy link
Copy Markdown
Owner

@joshjohanning I start a new job on Monday so will be busy for quite some time 👷‍♂️

Congrats @Wuodan! I wish you best of luck and prosperity 🎉

Thanks for all of your contributions here and the other actions 🚀 🚀

@joshjohanning joshjohanning merged commit 2f05f76 into joshjohanning:main May 6, 2026
1 check passed
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

📦 Draft Release Created

A draft release v2.9.5 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.

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