aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/header-gpl3.txt10
-rwxr-xr-xutil/pre-commit.py25
2 files changed, 26 insertions, 9 deletions
diff --git a/util/header-gpl3.txt b/util/header-gpl3.txt
index 058a0f7..a44bbfe 100644
--- a/util/header-gpl3.txt
+++ b/util/header-gpl3.txt
@@ -1,20 +1,20 @@
/** LICENSE ********************************************************************
- **
+ **
** smolbote: yet another qute browser
** Copyright (C) $CURRENTYEAR$ Xian Nox
- **
+ **
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
- **
+ **
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
- **
+ **
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
- **
+ **
******************************************************************************/
diff --git a/util/pre-commit.py b/util/pre-commit.py
index f8242f6..9282854 100755
--- a/util/pre-commit.py
+++ b/util/pre-commit.py
@@ -2,18 +2,35 @@
import os
import sys
+import subprocess
import glob
import license
# stash unstaged files before running test
os.system("git stash -q --keep-index")
-print("Running pre-commit hook in {0}".format(os.getcwd()))
+#print("Running pre-commit hook in {0}".format(os.getcwd()))
+problems = False
-problems = 0
-problems += license.lint("util/header-gpl3.txt", glob.glob("src/**/*.cpp") + glob.glob("src/**/*.h"), True)
+# check license
+print("Checking license...")
+if license.lint("util/header-gpl3.txt", glob.glob("src/**/*.cpp") + glob.glob("src/**/*.h"), True) > 0:
+ problems = True
+ print("Run <<./util/license.py -l util/header-gpl3.txt src/**/*.cpp src/**/*.h>> to autofix")
+
+# check style
+print("Checking style...")
+astyle = subprocess.run(['astyle', '--dry-run', '--formatted', '--options=astyle.rc'] + glob.glob("src/**/*.cpp") + glob.glob("src/**/*.h"), stdout=subprocess.PIPE)
+if len(astyle.stdout.splitlines()) > 0:
+ problems = True
+ for line in astyle.stdout.splitlines():
+ print(line.decode('utf-8'))
+ print("Run <<astyle --options=astyle.rc --suffix=none src/**/*.cpp src/**/*.h>> to autofix")
# restore stash
os.system("git stash pop -q")
-sys.exit(problems)
+if problems:
+ sys.exit(-1)
+else:
+ sys.exit(0)