Exemplo n.º 1
0
def analyse_git_repositories(path):
    for repo in m.get_git_repositories():
        full_path = os.path.join(path, get_git_repository_name(repo.url))
        if not os.path.isdir(full_path):
            print 'Folder %s not found, skipping' % full_path
            continue

        with cd(full_path):
            utc_zone = tz.tzutc()

            first = subprocess.check_output(["git rev-list --format=format:'%ai' --max-count=1 `git rev-list --max-parents=0 HEAD`"], shell=True)
            repo.first_commit_date_utc = parser.parse(first.splitlines()[1]).astimezone(utc_zone).replace(tzinfo=None)

            latest = subprocess.check_output(["git rev-list --format=format:'%ai' --max-count=1 `git rev-parse HEAD`"], shell=True)
            repo.latest_commit_date = parser.parse(latest.splitlines()[1]).astimezone(utc_zone).replace(tzinfo=None)

            repo.number_of_authors = subprocess.check_output(["git shortlog -sn | wc -l"], shell=True).strip()

            repo.number_of_commits = subprocess.check_output(["git log --oneline | wc -l"], shell=True).strip()

            repo.number_of_files = subprocess.check_output(["git ls-files | wc -l"], shell=True).strip()

            output = subprocess.check_output(["du -s --exclude=.git/*"], shell=True)
            repo.size_of_files = output.split()[0]

    analyze_used_languages(repo)
Exemplo n.º 2
0
def clone_git_repositories(path):
    for repo in m.get_git_repositories():
        url = repo.url.replace('git://', 'http://')
        outpath = os.path.join(path, get_git_repository_name(url))
        if os.path.exists(outpath):
            print 'Folder %s already present, skipping' % outpath
            continue

        try:
            print subprocess.check_output(['git', 'clone', url, outpath])
        except Exception, e:
            print e