diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-12-25 02:34:09 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-12-25 02:34:09 (GMT) |
commit | 0d0a7194226215703c5536fdae4993a4d4a81816 (patch) | |
tree | 10de369d72784edccaab9a34f7eb28911288c9ee /devbot/state.py | |
parent | d450954d31df8d22c96ccd76d6af1d983266a2d4 (diff) |
Refactor to put get_commit_id in the git module
Diffstat (limited to 'devbot/state.py')
-rw-r--r-- | devbot/state.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/devbot/state.py b/devbot/state.py index ae7fafd..83bbe9a 100644 --- a/devbot/state.py +++ b/devbot/state.py @@ -3,6 +3,7 @@ import os import json from devbot import config +from devbot import git _BUILT_MODULES = "builtmodules" _SYSTEM_CHECK = "syscheck" @@ -33,24 +34,33 @@ def _get_diff_hash(git_module): else: return None -def touch_built_module(module): +def _get_root_commit_id(): + git_module = git.get_root_module() + if git_module: + commit_id = git_module.get_commit_id() + else: + commit_id = "snapshot" + + return commit_id + +def built_module_touch(module): git_module = module.get_git_module() built_modules = _load_state(_BUILT_MODULES, {}) - info = {"commit": module.get_commit_id(), + info = {"commit": git_module.get_commit_id(), "diff_hash": _get_diff_hash(git_module)} built_modules[module.name] = info _save_state(_BUILT_MODULES, built_modules) -def remove_built_module(module): +def built_module_remove(module): built_modules = _load_state(_BUILT_MODULES) if built_modules and module.name in built_modules: del built_modules[module.name] _save_state(_BUILT_MODULES, built_modules) -def check_built_module(module): +def built_module_is_unchanged(module): git_module = module.get_git_module() built_modules = _load_state(_BUILT_MODULES, {}) if module.name not in built_modules: @@ -59,17 +69,18 @@ def check_built_module(module): info = built_modules[module.name] return info["diff_hash"] == _get_diff_hash(git_module) and \ - info["commit"] == module.get_commit_id() - -def get_last_system_check(): - system_check = _load_state(_SYSTEM_CHECK, {}) - return system_check.get("commit", None) + info["commit"] == git_module.get_commit_id() -def touch_last_system_check(): - system_check = _load_state(_SYSTEM_CHECK, {}) +def system_check_is_unchanged(): + system_check = _load_state(_SYSTEM_CHECK) + if not system_check: + return False - system_check["commit"] = config.get_commit_id() + return system_check["commit"] == _get_root_commit_id() +def system_check_touch(): + system_check = _load_state(_SYSTEM_CHECK, {}) + system_check["commit"] = _get_root_commit_id() _save_state(_SYSTEM_CHECK, system_check) def clean(): |