tools: add sensor node patch script
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PATCH_COMMIT="a701059"
|
||||||
|
|
||||||
|
repo_root="$(git rev-parse --show-toplevel)"
|
||||||
|
cd "$repo_root"
|
||||||
|
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
echo "Refusing to edit a dirty working tree." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git cat-file -e "${PATCH_COMMIT}^{commit}" 2>/dev/null; then
|
||||||
|
git fetch origin
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git merge-base --is-ancestor "$PATCH_COMMIT" HEAD; then
|
||||||
|
git cherry-pick "$PATCH_COMMIT"
|
||||||
|
else
|
||||||
|
echo "XIAO sensor-node patch is already applied."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f .venv/bin/activate ]]; then
|
||||||
|
echo "Missing .venv/bin/activate; create the project virtual environment first." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source .venv/bin/activate
|
||||||
|
python run_tests.py
|
||||||
|
|
||||||
|
git add -A
|
||||||
|
if ! git diff --cached --quiet; then
|
||||||
|
git commit -m "firmware: apply XIAO C6 sensor node patch"
|
||||||
|
fi
|
||||||
|
|
||||||
|
branch="$(git branch --show-current)"
|
||||||
|
if [[ -z "$branch" ]]; then
|
||||||
|
echo "Cannot push from detached HEAD." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git push origin "$branch"
|
||||||
Reference in New Issue
Block a user