chore: adopt clang-format and pre-commit #1128

Closed
prompterror wants to merge 1 commit from upstream-pr/1128 into main
prompterror commented 2026-10-07 13:16:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by prompterror on 2026-10-07T13:16:26Z.


What

Adopts a formatting/tooling baseline for the whole tree so style is enforced mechanically instead of by review:

  • .clang-format — LLVM base + deliberate deviations, all documented in the file: IndentWidth: 4 (the tree is 4-space indented), ColumnLimit: 120 (long shader-dump/profile lines are atomic; the tree already has 500-char lines), PointerAlignment: Left (matches the tree), SortIncludes: Never (include order is load-bearing here), FixNamespaceComments: false.
  • .editorconfig — LF, UTF-8, 4-space indent, final newline, no trailing whitespace; mirrors the hooks.
  • .pre-commit-config.yaml — pre-commit/pre-commit-hooks v6.0.0 (trailing-whitespace, end-of-file-fixer, check-yaml, check-merge-conflict, check-case-conflict, check-added-large-files, check-executables-have-shebangs, mixed-line-ending → LF) and pre-commit/mirrors-clang-format v21.1.8. Vendored code under 3rdparty/ is excluded from every hook.
  • .github/workflows/pre-commit.yml — CI job that runs pre-commit run --all-files on push to main and on pull requests, matching the existing Build workflow's checkout conventions.
  • CONTRIBUTING.md — documents pre-commit install and the format requirement.
  • Baseline reformat of core/ — clang-format -i (21.1.8, the pinned revision). Mechanical: line-wrapping at 120 columns, brace/indent normalization, single-statement blocks. No semantic changes (the working tree before this commit was already hook-clean, so CI --all-files passes).

The reformatting commit includes GuestMemory.cpp/ShaderMemory.cpp, which #1114 also touches — whichever merges second needs only a trivial rebase (git clang-format can't auto-merge formatting-only hunks, but the conflict is mechanical).

Testing

  • pre-commit run --all-files passes locally with the pinned revisions (provides the exact baseline CI will check).
  • Reformatting is whitespace/line-break only; verified there are no whitespace-insensitive content changes beyond the two minor fixes clang-format makes (if (x) return y; → two lines, one ( " typo in a profile string).

Note: CI runs on this fork PR are held by the first-time-contributor approval gate until a maintainer approves once (same as #1114).

Written with AI assistance; the config deviations and the baseline are reviewed per CONTRIBUTING.md.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4773202215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1128). Originally posted by [prompterror](https://github.com/prompterror) on 2026-10-07T13:16:26Z. --- ## What Adopts a formatting/tooling baseline for the whole tree so style is enforced mechanically instead of by review: - **`.clang-format`** — LLVM base + deliberate deviations, all documented in the file: `IndentWidth: 4` (the tree is 4-space indented), `ColumnLimit: 120` (long shader-dump/profile lines are atomic; the tree already has 500-char lines), `PointerAlignment: Left` (matches the tree), `SortIncludes: Never` (include order is load-bearing here), `FixNamespaceComments: false`. - **`.editorconfig`** — LF, UTF-8, 4-space indent, final newline, no trailing whitespace; mirrors the hooks. - **`.pre-commit-config.yaml`** — `pre-commit/pre-commit-hooks` **v6.0.0** (trailing-whitespace, end-of-file-fixer, check-yaml, check-merge-conflict, check-case-conflict, check-added-large-files, check-executables-have-shebangs, mixed-line-ending → LF) and `pre-commit/mirrors-clang-format` **v21.1.8**. Vendored code under `3rdparty/` is excluded from every hook. - **`.github/workflows/pre-commit.yml`** — CI job that runs `pre-commit run --all-files` on push to `main` and on pull requests, matching the existing Build workflow's checkout conventions. - **`CONTRIBUTING.md`** — documents `pre-commit install` and the format requirement. - **Baseline reformat of `core/`** — `clang-format -i` (21.1.8, the pinned revision). Mechanical: line-wrapping at 120 columns, brace/indent normalization, single-statement blocks. No semantic changes (the working tree before this commit was already hook-clean, so CI `--all-files` passes). The reformatting commit includes `GuestMemory.cpp`/`ShaderMemory.cpp`, which #1114 also touches — whichever merges second needs only a trivial rebase (`git clang-format` can't auto-merge formatting-only hunks, but the conflict is mechanical). ## Testing - `pre-commit run --all-files` passes locally with the pinned revisions (provides the exact baseline CI will check). - Reformatting is whitespace/line-break only; verified there are no whitespace-insensitive content changes beyond the two minor fixes clang-format makes (`if (x) return y;` → two lines, one `( "` typo in a profile string). Note: CI runs on this fork PR are held by the first-time-contributor approval gate until a maintainer approves once (same as #1114). Written with AI assistance; the config deviations and the baseline are reviewed per CONTRIBUTING.md.
github-actions[bot] commented 2026-10-07 13:55:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T13:55:00Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#959 sceNgs2PanGetVolumeMatrix
#1299 sceNpEntitlementAccessAbortRequest
sceNpEntitlementAccessDeleteRequest
#1606 asctime_nid_postfix
gmtime_nid_postfix
libc_mktime_nid_postfix
localtime_nid_postfix
mktime_nid_postfix
#2157 sceKernelConvertLocaltimeToUtc
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6039475663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1128#issuecomment-6039475663). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T13:55:00Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #959 | | `sceNgs2PanGetVolumeMatrix` | | | #1299 | | `sceNpEntitlementAccessAbortRequest`<br>`sceNpEntitlementAccessDeleteRequest` | | | #1606 | | `asctime_nid_postfix`<br>`gmtime_nid_postfix`<br>`libc_mktime_nid_postfix`<br>`localtime_nid_postfix`<br>`mktime_nid_postfix` | | | #2157 | | `sceKernelConvertLocaltimeToUtc` | |
adriadam10 commented 2026-10-08 07:56:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T07:56:19Z.


Thanks for the work here. This is a tree-wide policy change, so it needs a maintainer decision before a code review:

  • @boykopovar @oneandonlydean: do we want clang-format + a pre-commit CI job enforced on the whole tree? CONTRIBUTING doesn't have this rule today, and the baseline touches 1203 files (+82k/-50k).
  • A one-shot reformat conflicts with nearly every open PR (this branch already conflicts with main, and #1114 hit the same on GuestMemory.cpp/ShaderMemory.cpp). If accepted, it would need a merge window where open PRs are rebased/merged first, or a git blame ignore-revs file plus formatting only changed lines (git clang-format) as the CI check.
  • Author: please rebase on main and keep the baseline reformat in a separate PR from the config/CI files, so the config can be discussed without a 80k-line diff.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055412910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1128#issuecomment-6055412910). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T07:56:19Z. --- Thanks for the work here. This is a tree-wide policy change, so it needs a maintainer decision before a code review: - @boykopovar @oneandonlydean: do we want clang-format + a pre-commit CI job enforced on the whole tree? CONTRIBUTING doesn't have this rule today, and the baseline touches 1203 files (+82k/-50k). - A one-shot reformat conflicts with nearly every open PR (this branch already conflicts with `main`, and #1114 hit the same on `GuestMemory.cpp`/`ShaderMemory.cpp`). If accepted, it would need a merge window where open PRs are rebased/merged first, or a `git blame` ignore-revs file plus formatting only changed lines (`git clang-format`) as the CI check. - Author: please rebase on `main` and keep the baseline reformat in a separate PR from the config/CI files, so the config can be discussed without a 80k-line diff.
oneandonlydean commented 2026-10-09 09:21:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:21:54Z.


No from me: there's no formatter rule in CONTRIBUTING, and a whole-tree reformat would conflict with almost every open PR. I'd close this unless the owner wants one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078114597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1128#issuecomment-6078114597). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:21:54Z. --- No from me: there's no formatter rule in CONTRIBUTING, and a whole-tree reformat would conflict with almost every open PR. I'd close this unless the owner wants one.
oneandonlydean commented 2026-10-09 22:30:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T22:30:51Z.


Closing: a whole-tree reformat conflicts with nearly every open pull request, and we don't want a formatter rule for now. Thanks for the work on it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090335074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1128#issuecomment-6090335074). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T22:30:51Z. --- Closing: a whole-tree reformat conflicts with nearly every open pull request, and we don't want a formatter rule for now. Thanks for the work on it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1128
No description provided.