Skip to content

Commit 6a68510

Browse files
bblaceytekka007
authored andcommitted
Tool bundle updates (#693)
* Pre-commit --cached vs. less-efficient iteration * During pre-commit, leverage the git cppcheck --cached form instead of iterating over the cached files and invoking git cppcheck on each to eliminate redundant static analysis * Add support for Debian Linux on ARM * Check prerequisite tool minimum versions * Bootstrapping will now confirm that each prerequisite tool satisfies the minimum version required
1 parent 3be2516 commit 6a68510

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

.mystools/.bundle_runtime.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
#
77
##
88
log() { IFS=" "; >&2 printf "%s\n" "$*"; }
9-
warn() { IFS=" "; >&2 printf "\e[33m%s\e[m\n" "$*"; }
10-
err() { IFS=" "; >&2 printf '\e[31m%s\e[m\n' "$*"; exit 1; }
9+
info() { IFS=" "; >&2 printf "\e[92m%s\e[m\n" "$*"; }
10+
warn() { IFS=" "; >&2 printf "\e[93m%s\e[m\n" "$*"; }
11+
err() { IFS=" "; >&2 printf "\e[91m%s\e[m\n" "$*"; exit 1; }
1112

1213
is_supported_os()
1314
{
14-
[[ ${1} == darwin* ]] || [[ ${1} == linux-gnu ]] || [[ ${1} == freebsd ]] || [[ ${1} == msys ]] || [[ ${1} == cygwin ]]
15+
[[ ${1} == darwin* ]] || [[ ${1} == linux-gnu* ]] || [[ ${1} == freebsd ]] || [[ ${1} == msys ]] || [[ ${1} == cygwin ]]
1516
}
1617

1718
is_installed()

.mystools/bootstrap-dev.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@
1313
# Import common utility functions and environment variables
1414
. "$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)/.bundle_runtime.sh"
1515

16-
check_tool_prerequisites()
16+
check_tool_prerequisite()
1717
{
18-
local err=0
19-
for preReq in ${1}; do
20-
if ! is_installed $preReq; then
21-
warn "$preReq not installed or not in current path."
22-
err=1
18+
function ver { printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' '); }
19+
20+
if is_installed ${1} ; then
21+
#local version=$(${1} --version 2>&1 | sed -e 's/[[:alpha:]|(|[:space:]]//g')
22+
local version=$(${1} --version 2>&1 | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
23+
if [ $(ver ${version}) -lt $(ver ${2}) ]; then
24+
warn "Found ${1} ${version} however, version ${2} or greater is required..."
25+
return 1
2326
fi
24-
done
25-
return $err
27+
else
28+
warn "${1} not installed or not in current path."
29+
return 1
30+
fi
2631
}
2732

2833
check_git_remote()
@@ -68,7 +73,9 @@ check_git_remote "upstream" "${mysrepo}" || {
6873

6974
#3
7075
log "Checking tool/utility prerequisites..."
71-
check_tool_prerequisites "astyle cppcheck" || err "One or more required tools not found. Install required tools and re-run ${0}"
76+
check_tool_prerequisite "astyle" "2.0.5" || err "Install AStyle 2.0.5 or greater and re-run ${0}"
77+
check_tool_prerequisite "cppcheck" "1.76" || err "Install Cppcheck 1.76 or greater and re-run ${0}"
78+
check_tool_prerequisite "git" "2.0" || err "Install git 2.0 or greater and re-run ${0}"
7279

7380
#4
7481
log "Installing client-side git hooks..."
@@ -80,4 +87,4 @@ configure_git_tool_aliases || err "Failed to create git aliases due to error $?.
8087

8188
bootstrap_version "--set"
8289

83-
log "Successfully configured your repo for MySensors development... Thanks for your support!"
90+
info "Successfully configured your repo for MySensors development... Thanks for your support!"

.mystools/hooks/pre-commit.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ done
2020
###
2121
# cppcheck
2222
#
23-
errorsDetected=0
24-
for file in $(stagedSourceFiles); do
25-
if ! git cppcheck $file >/dev/null; then
26-
warn "$file failed static analysis."
27-
errorsDetected=1
28-
fi
29-
done
30-
31-
[ $errorsDetected == 1 ] && err "Correct the errors until cppcheck passees using 'git cppcheck --cached'."
23+
git cppcheck --cached || err "Correct the errors until cppcheck passes using 'git cppcheck --cached'."
3224

3325
exit 0

0 commit comments

Comments
 (0)