mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-28 16:29:07 +01:00
Compare commits
2 Commits
aab51eed2d
...
3a5f0962de
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a5f0962de | |||
| 507030d63b |
@ -138,6 +138,14 @@ repos:
|
|||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
# Fails a commit that still points crdt_sync at a local path. Local
|
||||||
|
# tests would go green against a library CI has never seen, silently.
|
||||||
|
- id: crdt-sync-override
|
||||||
|
name: no local crdt_sync dependency_override
|
||||||
|
entry: bash scripts/check_no_crdt_sync_override.sh stronglift_replacement/workout_app/pubspec.yaml
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
||||||
- id: shellcheck
|
- id: shellcheck
|
||||||
name: shellcheck
|
name: shellcheck
|
||||||
entry: bash -c 'printf "%s\0" "$@" | xargs -0 -n 40 shellcheck --severity=warning' --
|
entry: bash -c 'printf "%s\0" "$@" | xargs -0 -n 40 shellcheck --severity=warning' --
|
||||||
|
|||||||
@ -57,7 +57,14 @@ class RunnerUpDbMixin:
|
|||||||
root=True,
|
root=True,
|
||||||
)
|
)
|
||||||
if not ok:
|
if not ok:
|
||||||
_logger.info("Failed to copy RunnerUp DB to sdcard: %s", err)
|
_logger.warning(
|
||||||
|
"Root DB pull failed for %s (%s) — this device likely has no "
|
||||||
|
"root/su access, so this fallback path cannot work here. "
|
||||||
|
"RunnerUp workouts can only be verified via TCX export files; "
|
||||||
|
"enable RunnerUp's File Synchronizer auto-export on-device.",
|
||||||
|
pkg,
|
||||||
|
err,
|
||||||
|
)
|
||||||
shutil.rmtree(tmp_dir, ignore_errors=True)
|
shutil.rmtree(tmp_dir, ignore_errors=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -142,7 +149,12 @@ class RunnerUpDbMixin:
|
|||||||
"""Verify today's run via root DB pull (fallback path)."""
|
"""Verify today's run via root DB pull (fallback path)."""
|
||||||
db_path = self._pull_runnerup_db()
|
db_path = self._pull_runnerup_db()
|
||||||
if db_path is None:
|
if db_path is None:
|
||||||
return "not_verified", "Could not retrieve RunnerUp database from phone"
|
return (
|
||||||
|
"not_verified",
|
||||||
|
"No TCX export found and root DB access is unavailable on this "
|
||||||
|
"device — enable RunnerUp's File Synchronizer auto-export so "
|
||||||
|
"runs land in /sdcard/Documents/RunnerUp/",
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_data = self._query_todays_run(db_path)
|
run_data = self._query_todays_run(db_path)
|
||||||
|
|||||||
@ -138,6 +138,14 @@ class RunnerUpVerificationMixin(RunnerUpDbMixin):
|
|||||||
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
today = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d")
|
||||||
exports = self._find_runnerup_exports_for_date(today)
|
exports = self._find_runnerup_exports_for_date(today)
|
||||||
if not exports:
|
if not exports:
|
||||||
|
_logger.warning(
|
||||||
|
"No RunnerUp TCX export found for %s in %s — a run today will "
|
||||||
|
"not be verified unless RunnerUp's File Synchronizer "
|
||||||
|
"auto-export is enabled and the app stays enabled long enough "
|
||||||
|
"to sync (check it isn't disabled by focus mode).",
|
||||||
|
today,
|
||||||
|
RUNNERUP_EXPORT_DIRS,
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Try each file; return the best result (verified > validation error).
|
# Try each file; return the best result (verified > validation error).
|
||||||
@ -174,6 +182,13 @@ class RunnerUpVerificationMixin(RunnerUpDbMixin):
|
|||||||
continue
|
continue
|
||||||
status, msg = self._validate_runnerup_data(data)
|
status, msg = self._validate_runnerup_data(data)
|
||||||
if status != "verified":
|
if status != "verified":
|
||||||
|
_logger.warning(
|
||||||
|
"RunnerUp export %s for %s did not qualify (%s): %s",
|
||||||
|
remote,
|
||||||
|
date_str,
|
||||||
|
status,
|
||||||
|
msg,
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
workout_data = {
|
workout_data = {
|
||||||
"type": "runnerup_verified",
|
"type": "runnerup_verified",
|
||||||
@ -285,5 +300,6 @@ class RunnerUpVerificationMixin(RunnerUpDbMixin):
|
|||||||
return file_result
|
return file_result
|
||||||
|
|
||||||
# Path 2: root DB pull (fallback when no export files found yet).
|
# Path 2: root DB pull (fallback when no export files found yet).
|
||||||
_logger.info("No TCX exports found today; trying root DB pull...")
|
# On a non-rooted device this path cannot succeed; _verify_runnerup_via_db
|
||||||
|
# reports that plainly rather than as a generic failure.
|
||||||
return self._verify_runnerup_via_db()
|
return self._verify_runnerup_via_db()
|
||||||
|
|||||||
@ -234,8 +234,15 @@ class ScreenLocker(
|
|||||||
``workout-sync.timer`` unit calls. Sync used to happen only inside the
|
``workout-sync.timer`` unit calls. Sync used to happen only inside the
|
||||||
locker's startup path, so a workout finished after login stayed
|
locker's startup path, so a workout finished after login stayed
|
||||||
invisible until the next login.
|
invisible until the next login.
|
||||||
|
|
||||||
|
Also re-runs the RunnerUp TCX backfill here, not just at login: the
|
||||||
|
login-time scan gets exactly one shot, and if the phone isn't
|
||||||
|
adb-visible at that instant (e.g. USB debugging not yet
|
||||||
|
authorized), a same-day run stays uncredited until the next login.
|
||||||
|
Repeating it every 15 minutes closes that gap.
|
||||||
"""
|
"""
|
||||||
self._ingest_synced_manual_workouts()
|
self._ingest_synced_manual_workouts()
|
||||||
|
self._auto_fill_week_runnerup_bonus()
|
||||||
|
|
||||||
def _ingest_synced_manual_workouts(self) -> None:
|
def _ingest_synced_manual_workouts(self) -> None:
|
||||||
"""Sync manual workouts: publish this PC's, ingest everyone else's.
|
"""Sync manual workouts: publish this PC's, ingest everyone else's.
|
||||||
|
|||||||
88
scripts/check_no_crdt_sync_override.sh
Executable file
88
scripts/check_no_crdt_sync_override.sh
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# Fail if a pubspec still overrides crdt_sync with a local path.
|
||||||
|
#
|
||||||
|
# The apps depend on crdt_sync as a *git dependency pinned to a tag*, so what
|
||||||
|
# CI builds is whatever that tag points at. A `dependency_overrides:` entry
|
||||||
|
# pointing at ~/utils/crdt_sync_dart is invaluable while developing an unreleased
|
||||||
|
# library change -- and catastrophic if it survives the commit: local tests go
|
||||||
|
# green against code CI has never seen, and the failure is silent in both
|
||||||
|
# directions.
|
||||||
|
#
|
||||||
|
# A comment in the pubspec asking someone to remember is deployment hygiene,
|
||||||
|
# not a fix. This is the gate.
|
||||||
|
#
|
||||||
|
# Usage: check_no_crdt_sync_override.sh [pubspec.yaml ...]
|
||||||
|
# With no arguments, checks ./pubspec.yaml.
|
||||||
|
# ============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_NAME="$(basename "$0")"
|
||||||
|
readonly SCRIPT_NAME
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $SCRIPT_NAME [pubspec.yaml ...]"
|
||||||
|
echo " Fails when a pubspec overrides crdt_sync with a local path."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Returns 0 (found) when the file has a crdt_sync entry under
|
||||||
|
# dependency_overrides. Deliberately a small state machine rather than a grep:
|
||||||
|
# `path:` appears under plenty of other keys, and a false positive here blocks
|
||||||
|
# a legitimate commit.
|
||||||
|
has_override() {
|
||||||
|
local file="$1"
|
||||||
|
awk '
|
||||||
|
# Track indent depth explicitly. An earlier version used an awk
|
||||||
|
# interval expression ({1,4}) to spot a sibling key, which plain awk
|
||||||
|
# does not enable by default -- so the check silently never fired and
|
||||||
|
# reported every file clean. A safety check that fails open is worse
|
||||||
|
# than none, so this version is written to be obvious instead of terse.
|
||||||
|
function indent(line, n) {
|
||||||
|
n = match(line, /[^ ]/)
|
||||||
|
return (n == 0) ? 0 : n - 1
|
||||||
|
}
|
||||||
|
/^[[:space:]]*#/ { next } # comments
|
||||||
|
/^[[:space:]]*$/ { next } # blank lines
|
||||||
|
/^dependency_overrides:[[:space:]]*$/ { in_overrides = 1; next }
|
||||||
|
/^[^[:space:]]/ { in_overrides = 0; in_crdt = 0; next }
|
||||||
|
in_overrides {
|
||||||
|
if ($0 ~ /^[[:space:]]+crdt_sync:[[:space:]]*$/) {
|
||||||
|
in_crdt = 1
|
||||||
|
crdt_indent = indent($0)
|
||||||
|
next
|
||||||
|
}
|
||||||
|
# Any key at or above crdt_sync{s} own indent ends its block.
|
||||||
|
if (in_crdt && indent($0) <= crdt_indent) { in_crdt = 0 }
|
||||||
|
if (in_crdt && $0 ~ /^[[:space:]]+path:/) { found = 1 }
|
||||||
|
}
|
||||||
|
END { exit(found ? 0 : 1) }
|
||||||
|
' "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local -a files=("$@")
|
||||||
|
if [[ ${#files[@]} -eq 0 ]]; then
|
||||||
|
files=("pubspec.yaml")
|
||||||
|
fi
|
||||||
|
|
||||||
|
local failed=0
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
[[ -f "$file" ]] || continue
|
||||||
|
if has_override "$file"; then
|
||||||
|
echo "Error: $file still has a local crdt_sync dependency_override." >&2
|
||||||
|
echo " Remove it and bump the git 'ref:' to the released tag" >&2
|
||||||
|
echo " before committing, or CI will build different code." >&2
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return "$failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Loading…
Reference in New Issue
Block a user