Esempio n. 1
0
File: app.py Progetto: cholin/gix
def api_contributors(reponame):
    hit = '{0}-contributors'.format(reponame)
    entries = cache.get(hit)
    if entries is None:
        repo = Repository(reponame)
        commits = [
            (x.author.name) for x in repo.log(repo.head.target.hex)
            if len(x.parents) == 1
        ]
        entries = Counter(commits).items()
        cache.set(hit, entries, app.config['CACHE_TIME']);

    return jsonify(entries);
Esempio n. 2
0
File: app.py Progetto: cholin/gix
def api_activity(reponame):
    hit = '{0}-activity'.format(reponame)
    entries = cache.get(hit)
    if entries is None:
        repo = Repository(reponame)
        commits = [x for x in repo.log(repo.head.target.hex)]

        data = [utils.to_date(c.commit_time).strftime("%Y/%m/%d") for c in commits]
        data_sorted = sorted(Counter(data).items())
        entries = [{'date': k, 'commits': v} for k, v in data_sorted]
        cache.set(hit, entries, app.config['CACHE_TIME']);

    return jsonify(activity=entries);
Esempio n. 3
0
File: app.py Progetto: cholin/gix
def commits(reponame, revspec = None):
    repo = Repository(reponame)

    if revspec != None:
        rev = repo.revparse_single(revspec)
        formatter = HtmlFormatter(linenos='inline')
        diffs = []
        for parent in rev.parents:
            try:
                data = parent.tree.diff(rev.tree).patch
                diffs.append(highlight(data, DiffLexer(), formatter))
            except:
                pass

        return render_template("objects/commit.html",
                  repo= repo, rev = rev, diffs = diffs)

    log = repo.log(repo.head.target.hex)
    page = int(request.args.get('page', 0))
    revs = islice(log, 20*page, 20*(page+1))
    return render_template("objects/commits.html",
              repo = repo, revs = list(revs), page=page)