Skip to content

Add make-targets that format the lines a branch changed - #728

Merged
hannesa2 merged 1 commit into
masterfrom
make-format
Sep 25, 2026
Merged

hannesa2 merged 1 commit into
masterfrom
make-format

Conversation

@goneng

@goneng goneng commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Let contributors match the house style with the repository's own .clang-format before a reviewer has to point it out. Only the lines a branch changed are looked at: 34 of the 250 source files in Classes, GitXTests and GitXUITests are not formatted that way today, and checking whole files would flag them all.

Changes

  • make format reformats the lines changed since the branch left master, uncommitted ones included (git clang-format --force <base>). A new file counts once it is added to git.
  • make format-check shows the diff clang-format would apply and fails if there is one, with a tip to run make format.
  • After every make that builds (build, unit-test, ui-test, all-tests, archive), the unformatted files are listed next to the submodule and framework warnings, with the same tip. It never fails the build, and stays quiet on CI, without clang-format installed, or with no base to measure from.
  • The base is the merge-base with master on whichever remote points at gitx/gitx, since that remote is origin in a plain clone and often upstream in a fork. BASE=<commit> overrides it.

There is no CI step: the runners have no clang-format, and a different version of it may format the same code another way. That is for a separate discussion.

Test plan

  • On a clean branch, format-check passes and nothing is reported; after mangling a line, the build-end warning names the file, format-check shows the diff and fails, and format fixes it so format-check passes again.
  • Quiet with GITHUB_ACTIONS set and without clang-format on PATH (where format asks to brew install clang-format); a clone with no gitx/gitx remote asks for BASE=, and a bad BASE fails with git's error.
  • The remote match takes ssh and https URLs, with or without .git, and skips forks such as me/gitx.

Let contributors match the house style with the repository's own
.clang-format before a reviewer has to point it out.

- Add `make format`, which reformats the lines changed since the branch
  left gitx/gitx master, uncommitted ones included; `BASE=` overrides
  the starting point
- Add `make format-check`, which shows what would change and fails if
  anything would
- Report unformatted changed lines after every make that builds, the
  way submodule drift is reported, with a tip to run `make format`;
  it never fails a build and stays quiet on CI or without clang-format
@goneng
goneng marked this pull request as ready for review September 25, 2026 18:46
@goneng
goneng requested a review from hannesa2 September 25, 2026 18:46
@goneng goneng changed the title Add make targets that format the lines a branch changed Add make-targets that format the lines a branch changed Sep 25, 2026
@hannesa2
hannesa2 merged commit ddc0cee into master Sep 25, 2026
3 checks passed
@hannesa2
hannesa2 deleted the make-format branch September 25, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants