-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e62ecc9
Showing
706 changed files
with
291,903 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script checks only that the modified files follow pep8 | ||
|
||
# Fail on error | ||
set -e | ||
|
||
# Exit on pipe fail | ||
set -o pipefail | ||
|
||
PYLINT=${PYLINT:-pylint} | ||
BLACK=${BLACK:-black} | ||
|
||
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; } | ||
command -v ${PYLINT} >/dev/null 2>&1 || { echo >&2 "${PYLINT} is missing"; exit 1; } | ||
command -v ${BLACK} >/dev/null 2>&1 || { echo >&2 "${BLACK} is missing"; exit 1; } | ||
|
||
# check if stdout is a terminal. | ||
if test -t 1; then | ||
# see if it supports colors. | ||
ncolors=$(tput colors) | ||
if test -n "$ncolors" && test $ncolors -ge 8; then | ||
normal="$(tput sgr0)" | ||
red="$(tput setaf 1)" | ||
green="$(tput setaf 2)" | ||
fi | ||
fi | ||
|
||
# pylint returns a bitmask as status code: | ||
# | ||
# 0 no error | ||
# 1 fatal message issued | ||
# 2 error message issued | ||
# 4 warning message issued | ||
# 8 refactor message issued | ||
# 16 convention message issued | ||
# 32 usage error | ||
|
||
# grep will exit with 1 if no lines are found | ||
FILES=$(git --no-pager diff --diff-filter=d --name-only origin/master | grep -v "old/" | grep -E ".py\$" || exit 0) | ||
if [ -z "${FILES}" ] ; then | ||
exit 0 | ||
fi | ||
|
||
${BLACK} --check --fast ${FILES} | ||
|
||
${PYLINT} --persistent=no ${FILES} || { | ||
pylint_status=$? | ||
exitcode=0 | ||
if (( ${pylint_status} \& 1 )); then | ||
echo fatal messsage >&2 | ||
exitcode=2 | ||
fi | ||
if (( ${pylint_status} \& 2 )); then | ||
echo error messsage >&2 | ||
exitcode=2 | ||
fi | ||
if (( ${pylint_status} \& 4 )); then | ||
echo warning messsage >&2 | ||
exitcode=2 | ||
fi | ||
if (( ${pylint_status} \& 8 )); then | ||
echo refactor messsage >&2 | ||
fi | ||
if (( ${pylint_status} \& 16 )); then | ||
echo convention messsage >&2 | ||
fi | ||
# This should not happen! | ||
if (( ${pylint_status} \& 32 )); then | ||
echo usage error >&2 | ||
exitcode=2 | ||
fi | ||
exit ${exitcode} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script checks only that the modified files follow the code style. | ||
|
||
# Fail on error | ||
set -e | ||
|
||
# Exit on pipe fail | ||
set -o pipefail | ||
|
||
CLANGFORMAT=${CLANGFORMAT:-clang-format-7} | ||
|
||
command -v git >/dev/null 2>&1 || { echo >&2 "git is missing"; exit 1; } | ||
command -v xargs >/dev/null 2>&1 || { echo >&2 "xargs is missing"; exit 1; } | ||
command -v ${CLANGFORMAT} >/dev/null 2>&1 || { echo >&2 "${CLANGFORMAT} is missing"; exit 1; } | ||
|
||
# check if stdout is a terminal. | ||
if test -t 1; then | ||
# see if it supports colors. | ||
ncolors=$(tput colors) | ||
if test -n "$ncolors" && test $ncolors -ge 8; then | ||
normal="$(tput sgr0)" | ||
red="$(tput setaf 1)" | ||
green="$(tput setaf 2)" | ||
fi | ||
fi | ||
|
||
if git --no-pager diff --diff-filter=d --name-only origin/master | grep -v -E "(^src/(drivers|ui/fonts)|.*ugui.*|.*base32.*)" | grep -E "^(src|test)" | grep -E "\.(c|h)\$" | xargs -n1 "$CLANGFORMAT" -output-replacements-xml | grep -c "<replacement " >/dev/null; then | ||
echo -e "${red}Not $CLANGFORMAT clean${normal}" | ||
# Apply CF to the files | ||
git --no-pager diff --diff-filter=d --name-only origin/master | grep -v -E "(^src/(drivers|ui/fonts)|.*ugui.*|.*base32.*)" | grep -E "^(src|test)" | grep -E "\.(c|h)\$" | xargs -n1 "$CLANGFORMAT" -i | ||
# Print list of files that weren't formatted correctly | ||
echo -e "Incorrectly formatted files:" | ||
git --no-pager diff --name-only | ||
# Print the diff | ||
echo -e "Detailed git diff" | ||
git --no-pager diff | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Chromium | ||
ColumnLimit: 100 | ||
IndentWidth: 4 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AlignTrailingComments: false | ||
AllowShortLoopsOnASingleLine: true | ||
AllowShortIfStatementsOnASingleLine: true | ||
BinPackArguments: false | ||
BreakBeforeBraces: Linux | ||
IndentCaseLabels: false | ||
PenaltyReturnTypeOnItsOwnLine: 1000 | ||
SpacesBeforeTrailingComments: 1 | ||
# cmocka must come after some std includes | ||
IncludeCategories: | ||
- Regex: '^(<|")cmocka' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 1 | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
build | ||
build-vagrant | ||
version.h | ||
NOTES.md | ||
.vagrant | ||
.DS_Store | ||
.ycm* | ||
*.o | ||
*.pyc | ||
*.sw* | ||
*.bak | ||
*.bin | ||
!*.c | ||
|
||
# gnu global | ||
/src/GPATH | ||
/src/GRTAGS | ||
/src/GTAGS | ||
|
||
.vimrc | ||
external/* | ||
!external/cryptoauthlib | ||
!external/ctaes | ||
!external/CMakeLists.txt | ||
src/generated | ||
py/bitbox02/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[submodule "tools/nanopb"] | ||
path = tools/nanopb | ||
url = https://github.com/shiftdevices/nanopb.git | ||
[submodule "external/cryptoauthlib"] | ||
path = external/cryptoauthlib | ||
url = https://github.com/shiftdevices/cryptoauthlib.git | ||
[submodule "external/ctaes"] | ||
path = external/ctaes | ||
url = https://github.com/digitalbitbox/ctaes.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[MASTER] | ||
# hid is a c-extension, so we have to allow it to be loaded into python memory. | ||
extension-pkg-whitelist=hid | ||
|
||
[BASIC] | ||
# Shorter functions are excempt from docstring | ||
docstring-min-length=10 | ||
|
||
[MESSAGES CONTROL] | ||
# Black/pylint mismatch on code formatting | ||
disable=bad-continuation, fixme |
Oops, something went wrong.