From d52d9e778e793ee12f01be3fbfdeaef6843688da Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 3 Jul 2016 09:21:12 -0600 Subject: notify of new dependency even if target already done When a new dependency is discovered, its target may have already been placed on the TODO list via a different source (and maybe even analysed for dependencies), e.g. if find_dependencies() was previously called on it, or if it was previously found via recursion. In this case we still need to notify listeners of the dependency, even though we won't add it to the TODO list. --- git_deps/detector.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'git_deps') diff --git a/git_deps/detector.py b/git_deps/detector.py index 1c78a42..3111a38 100644 --- a/git_deps/detector.py +++ b/git_deps/detector.py @@ -198,6 +198,18 @@ class DependencyDetector(object): continue if dependency_sha1 not in self.dependencies[dependent_sha1]: + if not self.seen_commit(dependency): + self.notify_listeners("new_commit", dependency) + self.dependencies[dependent_sha1][dependency_sha1] = {} + + self.notify_listeners("new_dependency", + dependent, dependency, path, line_num) + + self.logger.debug( + " New dependency %s -> %s via line %s (%s)" % + (dependent_sha1[:8], dependency_sha1[:8], line_num, + GitUtils.oneline(dependency))) + if dependency_sha1 in self.todo_d: self.logger.debug( " Dependency on %s via line %s already in TODO" @@ -210,14 +222,6 @@ class DependencyDetector(object): (dependency_sha1[:8], line_num,)) continue - self.logger.debug( - " New dependency %s -> %s via line %s (%s)" % - (dependent_sha1[:8], dependency_sha1[:8], line_num, - GitUtils.oneline(dependency))) - self.dependencies[dependent_sha1][dependency_sha1] = {} - self.notify_listeners('new_commit', dependency) - self.notify_listeners('new_dependency', - dependent, dependency, path, line_num) if dependency_sha1 not in self.dependencies: if self.options.recurse: self.todo.append(dependency) -- cgit