Skip to content

Commit

Permalink
Merge branch 'main' into starTrekWatchface
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Jahn committed Jan 16, 2024
2 parents f12c20c + 034d83f commit a60b65a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
48 changes: 28 additions & 20 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#!/bin/bash
if clang-format --version | grep -q 'version 11\.'; then
CLANG_FORMAT_EXECUTABLE="clang-format"
else
CLANG_FORMAT_EXECUTABLE="clang-format-11"
#!/bin/sh

name="clang-format"

if [ -z "$(command -v "git-$name")" ]; then
name="$(basename -a $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'git-clang-format*') | sort | tail -n 1 | sed 's/^git-//')"
fi

if ! command -v $CLANG_FORMAT_EXECUTABLE &> /dev/null
then
echo $CLANG_FORMAT_EXECUTABLE does not exist, make sure to install it
exit 1
minVersion="14.0.0"

for file in $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'clang-format*'); do
curBin="$file"
curVersion="$("$curBin" --version | cut -d ' ' -f 3)"

if [ "$(printf '%s\n' "$curVersion" "$version" "$minVersion" | sort -V | tail -n 1)" = "$curVersion" ]; then
bin="$curBin"
version="$curVersion"
fi
done

if [ -z "$name" ] || [ -z "$bin" ]; then
echo "Could not find a suitable clang-format installation. Install clang-format that includes the git-clang-format script, with at least version $minVersion"
exit 1
fi

for FILE in $(git diff --cached --name-only)
do
if [[ "$FILE" =~ src/[A-Za-z0-9\ \-]+*\.(c|h|cpp|cc)$ ]]; then
echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
$CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
git add -- $FILE
elif [[ "$FILE" =~ src/(components|displayapp|drivers|heartratetask|logging|systemtask)/.*\.(c|h|cpp|cc)$ ]]; then
echo Autoformatting $FILE with $CLANG_FORMAT_EXECUTABLE
$CLANG_FORMAT_EXECUTABLE -style=file -i -- $FILE
git add -- $FILE
fi
args="--binary $bin -q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs"

changedFiles="$(git "$name" --diffstat $args)"
git "$name" $args

echo "$changedFiles" | head -n -1 | cut -d ' ' -f 2 | while read -r file; do
git add -- "$file"
done
9 changes: 3 additions & 6 deletions src/displayapp/screens/WatchFacePineTimeStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ void WatchFacePineTimeStyle::Refresh() {
}

currentWeather = weatherService.Current();

if (currentWeather.IsUpdated()) {
auto optCurrentWeather = currentWeather.Get();
if (optCurrentWeather) {
Expand All @@ -551,12 +550,10 @@ void WatchFacePineTimeStyle::Refresh() {
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
lv_label_set_text_fmt(temperature, "%d°", temp);
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
lv_obj_realign(temperature);
lv_obj_realign(weatherIcon);
} else {
lv_label_set_text(temperature, "--");
lv_label_set_text(weatherIcon, Symbols::ban);
}
} else {
lv_label_set_text(temperature, "--");
lv_label_set_text(weatherIcon, Symbols::ban);
lv_obj_realign(temperature);
lv_obj_realign(weatherIcon);
}
Expand Down

0 comments on commit a60b65a

Please sign in to comment.