From 4f9a11409b3b3ea9d2415472b29a481834089a1e Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Tue, 25 Dec 2012 01:22:46 +0000 Subject: Store built module commit in a dict So that we can store more info --- diff --git a/devbot/build.py b/devbot/build.py index 9823310..6a7f387 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -52,12 +52,7 @@ def build(): skipped = [] for module in modules[:]: - new_commit_id = module.get_commit_id() - if new_commit_id is None: - break - - old_commit_id = state.get_built_commit_id(module) - if old_commit_id == new_commit_id: + if state.check_built_module(module): modules.pop(0) skipped.append(module.name) else: @@ -68,7 +63,7 @@ def build(): print "\n".join(skipped) for module in modules: - state.remove_built_commit_id(module) + state.remove_built_module(module) for module in modules: if not _build_module(module, config.get_log_path("build")): @@ -226,7 +221,7 @@ def _build_module(module, log=None): except subprocess.CalledProcessError: return False - state.touch_built_commit_id(module) + state.touch_built_module(module) return True diff --git a/devbot/state.py b/devbot/state.py index 649b115..beba837 100644 --- a/devbot/state.py +++ b/devbot/state.py @@ -25,23 +25,25 @@ def _save_state(name, state): json.dump(state, f, indent=4) f.write('\n') -def touch_built_commit_id(module): +def touch_built_module(module): built_modules = _load_state(_BUILT_MODULES, {}) - built_modules[module.name] = module.get_commit_id() + info = {"commit": module.get_commit_id()} + built_modules[module.name] = info _save_state(_BUILT_MODULES, built_modules) -def remove_built_commit_id(module): +def remove_built_module(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 get_built_commit_id(module): +def check_built_module(module): built_modules = _load_state(_BUILT_MODULES, {}) - return built_modules.get(module.name, None) + info = built_modules.get(module.name, {}) + return module.get_commit_id() == info.get("commit", None) def get_last_system_check(): system_check = _load_state(_SYSTEM_CHECK, {}) -- cgit v0.9.1