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-28 00:41:02 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-28 00:41:49 (GMT)
commit31990083fe4272c0663ba13c936ecd7c759778fe (patch)
tree3163295867bdc218839e8a9b36c291e2609ee509 /devbot
parent28b6ca6d80dd16df32f1ba76de30a638bf287710 (diff)
Decide to rebuild on the base of files mtime
It's simpler and should be more reliable than using git (new files will be noticed).
Diffstat (limited to 'devbot')
-rw-r--r--devbot/git.py4
-rw-r--r--devbot/state.py33
2 files changed, 16 insertions, 21 deletions
diff --git a/devbot/git.py b/devbot/git.py
index f2da84d..29365f7 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -78,10 +78,6 @@ class Module:
return subprocess.check_output(["git", "describe"]).strip()
@_chdir
- def diff(self):
- return subprocess.check_output(["git", "diff"])
-
- @_chdir
def is_valid(self):
result = subprocess.call(["git", "rev-parse", "HEAD"],
stdout=utils.devnull,
diff --git a/devbot/state.py b/devbot/state.py
index 4fdc363..87434d1 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -11,27 +11,19 @@ _SYSTEM_CHECK = "syscheck"
def built_module_touch(module):
- git_module = git.get_module(module)
built_modules = _load_state(_BUILT_MODULES, {})
-
- info = {"commit": git_module.get_commit_id(),
- "diff_hash": _get_diff_hash(git_module)}
- built_modules[module.name] = info
-
+ built_modules[module.name] = {"source_hash": _compute_source_hash(module)}
_save_state(_BUILT_MODULES, built_modules)
def built_module_is_unchanged(module):
- git_module = git.get_module(module)
built_modules = _load_state(_BUILT_MODULES, {})
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"] == git_module.get_commit_id()
+ source_hash = built_modules[module.name].get("source_hash", None)
+ return source_hash == _compute_source_hash(module)
def system_check_is_unchanged():
system_check = _load_state(_SYSTEM_CHECK)
@@ -97,12 +89,19 @@ def _save_state(name, state):
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 _compute_source_hash(module):
+ # For some reason if source_dir is unicode
+ # we get a 10x slow down for some modules
+ source_dir = str(module.get_source_dir())
+
+ data = ""
+ for root, dirs, files in os.walk(source_dir):
+ for name in files:
+ path = os.path.join(root, name)
+ mtime = os.lstat(path).st_mtime
+ data = "%s%s %s\n" % (data, mtime, path)
+
+ return hashlib.sha256(data).hexdigest()
def _get_root_commit_id():