-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add .clang-format file which defines coding style as GNU #2851
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Language: Cpp | ||
BasedOnStyle: GNU | ||
ColumnLimit: 99 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# Tests that validate structure of the source code; | ||
# can be run without building it. | ||
set -euo pipefail | ||
set -eo pipefail | ||
|
||
if command -v clang-format >/dev/null && [ -n "$GITHUB_ACTOR" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...use |
||
git remote add github_actor https:///github.com/$GITHUB_ACTOR/ostree.git | ||
git remote add https_upstream https://github.com/ostreedev/ostree.git | ||
git fetch --recurse-submodules=no github_actor & | ||
git fetch --recurse-submodules=no https_upstream main & | ||
LOG_LINE=$(git show -s --format=%B | grep Merge) | ||
wait | ||
THIS_COMMIT=$(echo $LOG_LINE | awk '{print $2}') | ||
THAT_COMMIT=$(echo $LOG_LINE | awk '{print $4}') | ||
git reset --hard $THIS_COMMIT | ||
git rebase $THAT_COMMIT | ||
|
||
echo -n "Formatting with git clang-format... " | ||
if ! git clang-format $THAT_COMMIT; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What makes this a git subcommand? |
||
echo "git clang-format $THAT_COMMIT failed; run: please commit the changes" | ||
exit 1 | ||
fi | ||
echo "ok" | ||
fi | ||
|
||
# Don't hard require Rust | ||
if command -v cargo >/dev/null; then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ set -euo pipefail | |
set -x | ||
|
||
# First, basic static analysis | ||
./ci/codestyle.sh | ||
./ci/codestyle.sh clang-format | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this argument do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can remove the "clang-format" arg if needs be. I added it because I felt the ci/codestyle.sh shouldn't do git operations like fetch, rebase, etc. and apply reformats by default. But it's the only way I could thing of, of getting git clang-format to just look at the changes in a PR. If we reformat the whole codebase though, you can simply call clang-format to check the whole codebase. Another thing I've seen happen, just to be mindful of it if we start seeing it, is sometimes you have to do version checks eventually like only check if clang-format version is greater than 12. Because sometimes how it reformats between versions can change slightly, and you get into the situation where so some builds thing the style is ok, and some don't depending on clang-format version. This is the way I did it in inotify-tools CI, is we only support clang-format greater than 11 because earlier versions reformat a little differently: I didn't reformat the whole codebase in inotify-tools. Like I am proposing here, all new changes to inotify-tools are mandated to correspond with the .clang-format style. It avoids the "git blame" being confusing problem. |
||
|
||
NOCONFIGURE=1 ./autogen.sh | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ case "$ID" in | |
build-essential | ||
bubblewrap | ||
ca-certificates | ||
clang-format | ||
cpio | ||
debhelper | ||
dh-exec | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer we keep this and instead...