def all_dependencies(sha1, change_id, curr_project, curr_ref): """Return dependencies of the current commit. Returns all projects that have a not yet merged commit with a Change-Id that equals the current commit and any of its not yet merged parents. The return value is a tuple with two dicts with the project as a key and a 3-tuple consisting of the project name, path and Git ref. The first dict is for the immediate dependencies, the second is for transitive dependencies through parents. """ # The current commit is the first Change-Id in the list, the parents # come next change_ids = all_parent_change_ids(sha1, change_id) dependencies = {} transitive = {} commits = all_commits(change_ids[0], curr_project, curr_ref) for project, path, ref in commits: dependencies[project] = (project, path, ref) for change_id in change_ids[1:]: commits = all_commits(change_id, curr_project, curr_ref) for project, path, ref in commits: # Use only the most recent Change-Id of a project if project not in transitive: transitive[project] = (project, path, ref) transitive.update(dependencies) return dependencies, transitive
def all_dependencies(sha1): """Return dependencies of the current commit. Prints all projects that have a not yet merged commit with a Change-Id that equals the current commit or any of its not yet merged parents. The return value is a dict with the project as a key and a 3-tuple consisting of the project name, path and Git ref. """ change_ids = all_parent_change_ids(sha1) dependencies = {} # The current commit is the first Change-Id in the list, the parents # come next for change_id in change_ids: commits = all_commits(change_id) for project, path, ref in commits: # Use only the most recent Change-Id of a project if project not in dependencies: dependencies[project] = (project, path, ref) return dependencies