diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | CONTRIBUTING.md | 6 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | src/forms/blockerdialog.cpp | 20 | ||||
-rw-r--r-- | src/forms/blockerdialog.h | 20 | ||||
-rw-r--r-- | src/webengine/blockerrule.cpp | 20 | ||||
-rw-r--r-- | src/webengine/blockerrule.h | 20 | ||||
-rw-r--r-- | src/webengine/blockersubscription.cpp | 20 | ||||
-rw-r--r-- | src/webengine/blockersubscription.h | 20 | ||||
-rw-r--r-- | src/webengine/urlinterceptor.cpp | 20 | ||||
-rw-r--r-- | src/webengine/urlinterceptor.h | 20 | ||||
-rw-r--r-- | src/widgets/urllineedit.cpp | 20 | ||||
-rw-r--r-- | src/widgets/urllineedit.h | 20 | ||||
-rw-r--r-- | util/header-gpl3.txt | 2 | ||||
-rwxr-xr-x | util/license.py | 74 | ||||
-rwxr-xr-x | util/licensecheck.py | 59 | ||||
-rwxr-xr-x | util/pre-commit.py | 19 |
17 files changed, 306 insertions, 61 deletions
@@ -3,3 +3,6 @@ build* # QtCreator .pro.user settings *.user + +# python +__pycache__ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ba2457..7641c13 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,6 +11,12 @@ Please include the following when reporting bugs: ## Contributing +### Hooks +Symlink the hooks: +``` +ln -s ../../util/pre-commit.sh .git/hooks/pre-commit +``` + ### Versioning #### Major version @@ -11,4 +11,6 @@ It is supposed to be: It's a small boat. ### Sounds dumb, how do I use it? -You make it yourself after taking a cursory glance at BUILDING.md. +You make it yourself after taking a cursory glance at [BUILDING.md.][1] + +1: https://gitlab.com/xiannox/smolbote/blob/master/BUILDING.md diff --git a/src/forms/blockerdialog.cpp b/src/forms/blockerdialog.cpp index ee6bdfc..2660d7d 100644 --- a/src/forms/blockerdialog.cpp +++ b/src/forms/blockerdialog.cpp @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #include "blockerdialog.h" #include "ui_blockerdialog.h" diff --git a/src/forms/blockerdialog.h b/src/forms/blockerdialog.h index 59dce0a..9fc77ba 100644 --- a/src/forms/blockerdialog.h +++ b/src/forms/blockerdialog.h @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #ifndef URLINTERCEPTORDIALOG_H #define URLINTERCEPTORDIALOG_H diff --git a/src/webengine/blockerrule.cpp b/src/webengine/blockerrule.cpp index 340e8bd..6d49fa4 100644 --- a/src/webengine/blockerrule.cpp +++ b/src/webengine/blockerrule.cpp @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #include "blockerrule.h" BlockerRule::BlockerRule(QString rule, QObject *parent) : diff --git a/src/webengine/blockerrule.h b/src/webengine/blockerrule.h index ddbd1c9..1781f84 100644 --- a/src/webengine/blockerrule.h +++ b/src/webengine/blockerrule.h @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #ifndef ADBLOCKRULE_H #define ADBLOCKRULE_H diff --git a/src/webengine/blockersubscription.cpp b/src/webengine/blockersubscription.cpp index c7f647b..9275209 100644 --- a/src/webengine/blockersubscription.cpp +++ b/src/webengine/blockersubscription.cpp @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #include "blockersubscription.h" #include <QFile> diff --git a/src/webengine/blockersubscription.h b/src/webengine/blockersubscription.h index 1bb8919..814c712 100644 --- a/src/webengine/blockersubscription.h +++ b/src/webengine/blockersubscription.h @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #ifndef URLINTERCEPTORSUBSCRIPTION_H #define URLINTERCEPTORSUBSCRIPTION_H diff --git a/src/webengine/urlinterceptor.cpp b/src/webengine/urlinterceptor.cpp index 2bd50b8..0b94a76 100644 --- a/src/webengine/urlinterceptor.cpp +++ b/src/webengine/urlinterceptor.cpp @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #include "urlinterceptor.h" UrlRequestInterceptor::UrlRequestInterceptor(QObject *parent) : diff --git a/src/webengine/urlinterceptor.h b/src/webengine/urlinterceptor.h index 31f1256..e60fd91 100644 --- a/src/webengine/urlinterceptor.h +++ b/src/webengine/urlinterceptor.h @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #ifndef ADBLOCKINTERCEPTOR_H #define ADBLOCKINTERCEPTOR_H diff --git a/src/widgets/urllineedit.cpp b/src/widgets/urllineedit.cpp index 10b8356..b5082f1 100644 --- a/src/widgets/urllineedit.cpp +++ b/src/widgets/urllineedit.cpp @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #include "urllineedit.h" #include <QUrl> diff --git a/src/widgets/urllineedit.h b/src/widgets/urllineedit.h index 546ca41..3405461 100644 --- a/src/widgets/urllineedit.h +++ b/src/widgets/urllineedit.h @@ -1,3 +1,23 @@ +/** LICENSE ******************************************************************** + ** + ** smolbote: yet another qute browser + ** Copyright (C) 2017 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/>. + ** + ******************************************************************************/ + #ifndef URLLINEEDIT_H #define URLLINEEDIT_H diff --git a/util/header-gpl3.txt b/util/header-gpl3.txt index 939e526..058a0f7 100644 --- a/util/header-gpl3.txt +++ b/util/header-gpl3.txt @@ -1,7 +1,7 @@ /** LICENSE ******************************************************************** ** ** smolbote: yet another qute browser - ** Copyright (C) $CURRENTYEAR$ $AUTHOR$ + ** 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 diff --git a/util/license.py b/util/license.py new file mode 100755 index 0000000..0bbc6be --- /dev/null +++ b/util/license.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +import argparse +import datetime +import sys + +def readLicense(licenseFile): + with open(licenseFile) as rawlicense: + licensetext = rawlicense.read() + + # fill in the year + licensetext = licensetext.replace('$CURRENTYEAR$', str(datetime.datetime.now().year)) + + return licensetext + +def hasLicense(sourceFile): + with open(sourceFile) as source: + if source.readline().startswith('/** LICENSE **'): + return True + else: + return False + +def addLicense(sourceFile, licenseText): + with open(sourceFile, 'r') as source: + origData = source.read() + with open(sourceFile, 'w') as source: + source.write(licenseText + origData) + +def lint(license, src, dryRun, verbose=False): + if verbose is True: + print("license={0}".format(license)) + print("source={0}".format(src)) + + # read license file + licensetext = readLicense(license) + if verbose is True: + print("-- license text --") + print(licensetext) + print("-- license text --") + + if len(src) is 0: + print("No files to process.") + return 0 + + # open source file and check for license + numFaults = 0 + for filename in src: + if hasLicense(filename) is True: + if verbose: + print("OK {0}".format(filename)) + else: + if dryRun is True: + if verbose: + print("fail {0}".format(filename)) + else: + addLicense(filename, licensetext) + print("fix {0}".format(filename)) + + numFaults += 1 + + if numFaults is not 0: + print("License check: number of faults: {0}".format(numFaults)) + + return numFaults + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='check source files for license') + parser.add_argument('-l', '--license', required=True, help="use this file as license header template") + parser.add_argument('-v', '--verbose', action='store_true', help="print additional information") + parser.add_argument('-c', '--dry-run', action='store_true', help="don't modify any files, only check for licenses") + parser.add_argument('src', nargs='*', help="list of files to check") + args = parser.parse_args() + + sys.exit(lint(args.license, args.src, args.dry_run, args.verbose)) diff --git a/util/licensecheck.py b/util/licensecheck.py deleted file mode 100755 index be6de9a..0000000 --- a/util/licensecheck.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 - -# TODO: username argument -# TODO: updating licenses - -import argparse -import datetime - -def getLicense(licenseFile): - with open(licenseFile) as rawlicense: - licensetext = rawlicense.read() - - # fill in name and year - licensetext = licensetext.replace('$AUTHOR$', 'Xian Nox') - licensetext = licensetext.replace('$CURRENTYEAR$', str(datetime.datetime.now().year)) - - return licensetext - -def hasLicense(sourceFile): - with open(sourceFile) as source: - if source.readline().startswith('/** LICENSE **'): - return True - else: - return False - -def fix(sourceFile, licenseText): - with open(sourceFile, 'r') as source: - origData = source.read() - with open(sourceFile, 'w') as source: - source.write(licenseText + origData) - -def main(license, src, verbose=False): - if verbose is True: - print("Using license header {0}".format(license)) - print("Going through {0}".format(src)) - - # read license file - licensetext = getLicense(license) - #print(licensetext) - - # open source file and check for license - for filename in src: - if hasLicense(filename): - print("{0} has license".format(filename)) - else: - fix(filename, licensetext) - print("{0} license added".format(filename)) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Check source files for license') - parser.add_argument('-l', '--license', required=True) - parser.add_argument('-v', '--verbose', action='store_true') - parser.add_argument('src', nargs='*') - args = parser.parse_args() - - main(args.license, args.src, args.verbose) -else: - print('Do not use this as an import!') - sys.exit(-1) diff --git a/util/pre-commit.py b/util/pre-commit.py new file mode 100755 index 0000000..f8242f6 --- /dev/null +++ b/util/pre-commit.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import os +import sys +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())) + +problems = 0 +problems += license.lint("util/header-gpl3.txt", glob.glob("src/**/*.cpp") + glob.glob("src/**/*.h"), True) + +# restore stash +os.system("git stash pop -q") + +sys.exit(problems) |