Skip to content

Commit 34744a7

Browse files
awegrzynBarthelemy
authored andcommitted
Add travis clang-format job
1 parent e4b8708 commit 34744a7

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

.clang-format

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
BasedOnStyle: Google
2+
AccessModifierOffset: -1
3+
AlignEscapedNewlinesLeft: true
4+
AlignTrailingComments: true
5+
AllowAllParametersOfDeclarationOnNextLine: false
6+
AllowShortFunctionsOnASingleLine: true
7+
AllowShortIfStatementsOnASingleLine: false
8+
AllowShortLoopsOnASingleLine: false
9+
#AlwaysBreakBeforeMultilineStrings: true
10+
AlwaysBreakTemplateDeclarations: true
11+
BinPackParameters: true
12+
BreakBeforeBinaryOperators: false
13+
BreakBeforeBraces: Linux
14+
BreakBeforeTernaryOperators: true
15+
BreakConstructorInitializersBeforeComma: false
16+
ColumnLimit: 0
17+
CommentPragmas: '^ IWYU pragma:'
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
ConstructorInitializerIndentWidth: 2
20+
ContinuationIndentWidth: 2
21+
Cpp11BracedListStyle: false
22+
DerivePointerBinding: false
23+
ExperimentalAutoDetectBinPacking: false
24+
IndentCaseLabels: true
25+
IndentFunctionDeclarationAfterType: true
26+
IndentWidth: 2
27+
# It is broken on windows. Breaks all #include "header.h"
28+
Language: Cpp
29+
MaxEmptyLinesToKeep: 1
30+
KeepEmptyLinesAtTheStartOfBlocks: true
31+
NamespaceIndentation: None
32+
ObjCSpaceAfterProperty: false
33+
ObjCSpaceBeforeProtocolList: false
34+
PenaltyBreakBeforeFirstCallParameter: 1
35+
PenaltyBreakComment: 300
36+
PenaltyBreakFirstLessLess: 120
37+
PenaltyBreakString: 1000
38+
PenaltyExcessCharacter: 1000000
39+
PenaltyReturnTypeOnItsOwnLine: 200
40+
SortIncludes: false
41+
SpaceBeforeAssignmentOperators: true
42+
SpaceBeforeParens: ControlStatements
43+
SpaceInEmptyParentheses: false
44+
SpacesBeforeTrailingComments: 1
45+
SpacesInAngles: false
46+
SpacesInContainerLiterals: true
47+
SpacesInCStyleCastParentheses: false
48+
SpacesInParentheses: false
49+
Standard: Cpp11
50+
TabWidth: 2
51+
UseTab: Never

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: cpp
2+
matrix:
3+
include:
4+
- os: linux
5+
dist: xenial
6+
env: TOOL=clang-format
7+
addons:
8+
apt:
9+
sources:
10+
- llvm-toolchain-xenial-7
11+
packages:
12+
- clang-format-7
13+
compiler: clang
14+
script:
15+
- if [[ $TOOL == "clang-format" ]] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
16+
cd $TRAVIS_BUILD_DIR;
17+
BASE_COMMIT=$(git rev-parse $TRAVIS_BRANCH);
18+
COMMIT_FILES=$(git diff --name-only $BASE_COMMIT | grep -i -v LinkDef);
19+
RESULT_OUTPUT="$(git-clang-format-7 --commit $BASE_COMMIT --diff --binary `which clang-format-7` $COMMIT_FILES)";
20+
if [ "$RESULT_OUTPUT" == "no modified files to format" ] || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ] ; then
21+
exit 0;
22+
else
23+
echo "$RESULT_OUTPUT";
24+
exit 1;
25+
fi
26+
fi
27+
notifications:
28+
email: false

0 commit comments

Comments
 (0)