@@ -0,0 +1,1754 @@
+# -*- coding: utf-8 -*-%0A%0Aimport envoy%0Afrom allmychanges.utils import cd, get_package_metadata%0A%0A%0Adef git_clone(repo_path, path):%0A    %22%22%22Clone git repo from repo_path to local path%22%22%22%0A    r = envoy.run('git clone %7Brepo%7D %7Bpath%7D'.format(repo=repo_path, path=path))%0A    if r.status_code != 0 and r.std_err != '':%0A        return False%0A    return True%0A%0A%0Adef git_log_hash(path):%0A    %22%22%22Return list of tuples ('hash', 'commit message')%22%22%22%0A    splitter = '-----======!!!!!!======-----'%0A    with cd(path):%0A        r = envoy.run('git log --pretty=format:%22%25H%25n%25B%25n%7Bsplitter%7D%22'.format(splitter=splitter))%0A        lst = %5B%5D%0A        for group in r.std_out.split(splitter)%5B:-1%5D:%0A            _hash, msg = group.strip().split('%5Cn', 1)%0A            lst.append((_hash, msg))%0A        return reversed(lst)%0A%0A%0Adef git_checkout(path, revision_hash):%0A    with cd(path):%0A        r = envoy.run('git checkout %7Brevision%7D'.format(revision=revision_hash))%0A        if r.status_code == 0:%0A            return True%0A        return False%0A%0A%0Adef aggregate_git_log(path):%0A    %22%22%22Return dict: version -%3E list of commit messages%22%22%22%0A    versions = dict()%0A%0A    history_hashes = git_log_hash(path)%0A    if not history_hashes:%0A        return versions%0A%0A    current_version, current_commits = None, list()%0A%0A    for rev_hash, msg in git_log_hash(path):%0A        current_commits.append(msg)%0A        if git_checkout(path=path, revision_hash=rev_hash):%0A            version = get_package_metadata(path=path, field_name='Version')%0A            if version != current_version:%0A                # memorize it%0A                versions%5Bversion%5D = current_commits%0A                current_version, current_commits = version, list()%0A%0A    if current_commits:%0A        versions%5B'newest'%5D = current_commits%0A%0A    return versions%0A

Add git-log crawler.