Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-25 01:45:09 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-25 01:45:09 (GMT)
commitd450954d31df8d22c96ccd76d6af1d983266a2d4 (patch)
tree9a5cd975ac800664814383481d71158b8dfa1fcf /devbot
parent4f9a11409b3b3ea9d2415472b29a481834089a1e (diff)
Rebuild if the source tree changed
Diffstat (limited to 'devbot')
-rw-r--r--devbot/git.py4
-rw-r--r--devbot/state.py22
2 files changed, 23 insertions, 3 deletions
diff --git a/devbot/git.py b/devbot/git.py
index 1e361f0..8f6699c 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -72,6 +72,10 @@ class Module:
return subprocess.check_output(["git", "describe"]).strip()
@_chdir
+ def diff(self):
+ return subprocess.check_output(["git", "diff"])
+
+ @_chdir
def get_annotation(self, tag):
# FIXME this is fragile, there must be a better way
diff --git a/devbot/state.py b/devbot/state.py
index beba837..ae7fafd 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -1,3 +1,4 @@
+import hashlib
import os
import json
@@ -25,10 +26,19 @@ def _save_state(name, state):
json.dump(state, f, indent=4)
f.write('\n')
+def _get_diff_hash(git_module):
+ diff = git_module.diff().strip()
+ if diff:
+ return hashlib.sha256(diff).hexdigest()
+ else:
+ return None
+
def touch_built_module(module):
+ git_module = module.get_git_module()
built_modules = _load_state(_BUILT_MODULES, {})
- info = {"commit": module.get_commit_id()}
+ info = {"commit": module.get_commit_id(),
+ "diff_hash": _get_diff_hash(git_module)}
built_modules[module.name] = info
_save_state(_BUILT_MODULES, built_modules)
@@ -41,9 +51,15 @@ def remove_built_module(module):
_save_state(_BUILT_MODULES, built_modules)
def check_built_module(module):
+ git_module = module.get_git_module()
built_modules = _load_state(_BUILT_MODULES, {})
- info = built_modules.get(module.name, {})
- return module.get_commit_id() == info.get("commit", None)
+ if module.name not in built_modules:
+ return False
+
+ 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, {})