refactor: repository settings sync internals#186
Conversation
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
e2abe72 to
c58ad70
Compare
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.
|
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 👷♂️ |
There was a problem hiding this comment.
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_analysistoggles. - Introduced a small per-repo
ctxobject to avoid repeatedly threading the same parameters through toggle handlers. - Replaced the repeated repository settings diff/update logic with a
REPOSITORY_SETTING_FIELDSdescriptor 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
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>
Congrats @Wuodan! I wish you best of luck and prosperity 🎉 Thanks for all of your contributions here and the other actions 🚀 🚀 |
📦 Draft Release CreatedA draft release v2.9.5 has been created for this PR. Next Steps
|
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:
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.
This PR includes commits from other PRs:
and I would merge those first as they change less and at least feat: add private vulnerability reporting syncing support #185 affects this PR here.