forked from tobami/codespeed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,062 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.contrib.syndication.feeds import Feed | ||
from codespeed.models import Report | ||
from codespeed import settings | ||
|
||
|
||
class LatestEntries(Feed): | ||
title = settings.website_name | ||
link = "/changes/" | ||
description = "Last benchmark runs" | ||
|
||
def items(self): | ||
return Report.objects.order_by('-revision')[:10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os, datetime | ||
from subprocess import Popen, PIPE | ||
from speedcenter import settings | ||
|
||
|
||
path = settings.BASEDIR + '/repos/' | ||
|
||
def updaterepo(repo): | ||
repodir = path + repo.split('/')[-1] + "/" | ||
if os.path.exists(repodir): | ||
# Update repo | ||
cmd = "hg pull -u" | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=repodir) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
return [{'error': False}] | ||
else: | ||
# Clone repo | ||
cmd = "hg clone %s" % repo | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=path) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
return [{'error': False}] | ||
|
||
def getlogs(endrev, startrev): | ||
repodir = path + endrev.project.repo_path.split('/')[-1] + "/" | ||
if not os.path.exists(repodir): | ||
updaterepo(endrev.project.repo_path) | ||
|
||
cmd = "hg log -r %s:%s -b default --template '{rev}:{node|short}\n{author|person} / {author|user}\n{date}\n{desc}\n=newlog=\n'" % (endrev.commitid, startrev.commitid) | ||
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, cwd=repodir) | ||
stdout, stderr = p.communicate() | ||
if stderr: | ||
return [{'error': True, 'message': stderr}] | ||
else: | ||
logs = [] | ||
for log in stdout.split("=newlog=\n"): | ||
commitid, author, date, message = ("","","","") | ||
elements = [] | ||
elements = log.split('\n')[:-1] | ||
if len(elements) < 4: | ||
# Don't save "malformed" log | ||
continue | ||
else: | ||
commitid = elements.pop(0) | ||
author = elements.pop(0) | ||
date = elements.pop(0) | ||
# All other newlines should belong to the description text. Join. | ||
message = '\n'.join(elements) | ||
|
||
# Parse date | ||
date = date.split('-')[0] | ||
date = datetime.datetime.fromtimestamp(float(date)).strftime("%Y-%m-%d %H:%M:%S") | ||
|
||
# Add changeset info | ||
logs.append({ | ||
'date': date, 'author': author, | ||
'message': message,'commitid': commitid}) | ||
return logs |
Oops, something went wrong.