diff --git a/ci/scripts/format b/ci/scripts/format index 670e5e299e..bacea6779a 100755 --- a/ci/scripts/format +++ b/ci/scripts/format @@ -52,6 +52,20 @@ print_help() { echo " -s, --only-staged Only format staged files" echo " -v, --verbose Enable verbose output" echo " -h, --help Show this help message" + echo "" + echo "Uses the following clang-format style:" + echo " { $(echo "${clang_style}" | sed 's/[{}]//g; s/, */;\n /g')" } + echo "" + echo "Formats files with the following extensions: ${extensions_to_style_check}" + echo "in the following directories:" + echo " ${dirs_to_style_check}" | fold -s -w 80 | sed '2,$s/^/ /' + echo "" + echo "Examples:" + echo " Format changes against upstream/main (useful before opening a PR to upstream/main):" + echo " $0 -b upstream/main" + echo "" + echo " Check format for staged changes against HEAD (useful for a pre-commit hook):" + echo " $0 --dry-run --only-staged --compare-base $(git rev-parse --short HEAD)" } while [[ $# -gt 0 ]]; do diff --git a/docs/pages/overview/contrib.md b/docs/pages/overview/contrib.md index 57801d851b..17d9a5c522 100644 --- a/docs/pages/overview/contrib.md +++ b/docs/pages/overview/contrib.md @@ -10,13 +10,9 @@ Please submit a pull request! We welcome code and idea contributions. ### Indentation, etc. -Comdb2 contains code from multiple open source libraries. If editing existing code for, for example, BerkeleyDB and -SQLite, please stick to existing conventions for those code bases. For Comdb2 code, it's highly recommended that -before you creating a pull request, please format your code with `clang` via the following: - -``` -clang-format -style="{BasedOnStyle: llvm, IndentWidth: 4, UseTab: Never, BreakBeforeBraces: Linux, SortIncludes: false, IndentCaseLabels: false, AlwaysBreakTemplateDeclarations: true, AllowShortFunctionsOnASingleLine: false, AllowShortCaseLabelsOnASingleLine: true, AllowShortIfStatementsOnASingleLine: true}" -``` +Comdb2 contains code from multiple open source libraries. If editing existing code for, for example, BerkeleyDB and +SQLite, please stick to existing conventions for those code bases. For Comdb2 code, you can check your formatting +using the `ci/scripts/format` script. Run `./ci/scripts/format -h` for details. ### Producing trace