aboutsummaryrefslogtreecommitdiffstats
path: root/notifier.py
diff options
context:
space:
mode:
Diffstat (limited to 'notifier.py')
-rw-r--r--notifier.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/notifier.py b/notifier.py
index d061181..7e2e4c7 100644
--- a/notifier.py
+++ b/notifier.py
@@ -29,8 +29,7 @@ import re
import subprocess
import time
-import git_utils
-
+# pylint: disable=invalid-name
def parse_args():
"""Parses commandline arguments."""
@@ -96,6 +95,15 @@ def _send_email(proj, latest_ver, recipient, upgrade_log):
encoding='ascii')
+COMMIT_PATTERN = r'^[a-f0-9]{40}$'
+COMMIT_RE = re.compile(COMMIT_PATTERN)
+
+
+def is_commit(commit: str) -> bool:
+ """Whether a string looks like a SHA1 hash."""
+ return bool(COMMIT_RE.match(commit))
+
+
NOTIFIED_TIME_KEY_NAME = 'latest_notified_time'
@@ -106,7 +114,7 @@ def _should_notify(latest_ver, proj_history):
timestamp = proj_history.get(NOTIFIED_TIME_KEY_NAME, 0)
time_diff = datetime.today() - datetime.fromtimestamp(timestamp)
- if git_utils.is_commit(latest_ver) and time_diff <= timedelta(days=30):
+ if is_commit(latest_ver) and time_diff <= timedelta(days=30):
return False
return True
@@ -156,6 +164,7 @@ def send_notification(args):
def _upgrade(proj):
+ # pylint: disable=subprocess-run-check
out = subprocess.run([
'out/soong/host/linux-x86/bin/external_updater', 'update',
'--branch_and_commit', '--push_change', proj
@@ -188,6 +197,7 @@ def _check_updates(args):
params += args.paths
print(_get_android_top())
+ # pylint: disable=subprocess-run-check
subprocess.run(params, cwd=_get_android_top())