Skip to content

Commit 664960e

Browse files
authored
Improve pre-commit (#231)
* Run clang-format only on staged files * Add format message * Add better printing
1 parent 74d1205 commit 664960e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.githooks/pre-commit

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ then
55
exit
66
fi
77

8-
for f in $(find Team20/Code20/ -name "*.h" -or -name "*.cpp"); do
9-
clang-format --style=file -i "$f"
8+
echo "Running clang-format"
9+
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).cpp$' -e '\(.*\).h$' | while read line; do
10+
echo "Formatting: $line"
11+
clang-format --style=file -i "$line"
12+
git add "$line"
1013
done

Team20/Code20/UnitTesting/TestPQLParser.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ TEST_METHOD(TestParse_WithClause) {
483483
Reference{PqlToken{TokenType::NUMBER, "34"}}}};
484484
Assert::IsTrue(actual == expected);
485485
}
486+
486487
TEST_METHOD(TestParse_WithClauseRawRefsNotMatching_ThrowsException) {
487488
const std::vector<PqlToken> input = {
488489
{TokenType::IF}, {TokenType::SYNONYM, "i"},

Team20/Code20/source/PQL.h

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct PqlToken {
7676
PqlToken(TokenType specifiedTokenType, std::string specifiedValue = "")
7777
: type{specifiedTokenType}, value{specifiedValue} {}
7878
};
79+
7980
enum class AttributeRefType {
8081
PROCNAME,
8182
VARNAME,

0 commit comments

Comments
 (0)