Commit b4a8882a authored by Miquel Torres's avatar Miquel Torres
Browse files

Remove DEF_BRANCH from settings

parent c7ce34e9
...@@ -3,26 +3,28 @@ ...@@ -3,26 +3,28 @@
"pk": 1, "pk": 1,
"model": "codespeed.project", "model": "codespeed.project",
"fields": { "fields": {
"repo_type": "N", "repo_type": "G",
"name": "MyProject", "name": "MyProject",
"commit_browsing_url": "", "commit_browsing_url": "",
"repo_user": "", "repo_user": "",
"track": true, "track": true,
"repo_pass": "", "repo_pass": "",
"repo_path": "" "repo_path": "",
"default_branch": "master"
} }
}, },
{ {
"pk": 2, "pk": 2,
"model": "codespeed.project", "model": "codespeed.project",
"fields": { "fields": {
"repo_type": "N", "repo_type": "M",
"name": "Other", "name": "Other",
"commit_browsing_url": "", "commit_browsing_url": "",
"repo_user": "", "repo_user": "",
"track": true, "track": true,
"repo_pass": "", "repo_pass": "",
"repo_path": "" "repo_path": "",
"default_branch": "default"
} }
}, },
{ {
......
...@@ -139,7 +139,7 @@ class Revision(models.Model): ...@@ -139,7 +139,7 @@ class Revision(models.Model):
else: else:
date = self.date.strftime("%b %d, %H:%M") date = self.date.strftime("%b %d, %H:%M")
string = " - ".join(filter(None, (date, self.commitid, self.tag))) string = " - ".join(filter(None, (date, self.commitid, self.tag)))
if self.branch.name != settings.DEF_BRANCH: if self.branch.name != self.branch.project.default_branch:
string += " - " + self.branch.name string += " - " + self.branch.name
return string return string
......
...@@ -6,9 +6,6 @@ WEBSITE_NAME = "MySpeedSite" # This name will be used in the reports RSS feed ...@@ -6,9 +6,6 @@ WEBSITE_NAME = "MySpeedSite" # This name will be used in the reports RSS feed
DEF_ENVIRONMENT = None # Name of the environment which should be selected as default DEF_ENVIRONMENT = None # Name of the environment which should be selected as default
DEF_BRANCH = "master" # Defines the default branch to be used.
# In git projects, this branch is usually called "master"
DEF_BASELINE = None # Which executable + revision should be default as a baseline DEF_BASELINE = None # Which executable + revision should be default as a baseline
# Given as the name of the executable and commitid of the revision # Given as the name of the executable and commitid of the revision
# Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'} # Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'}
......
...@@ -3,7 +3,6 @@ from datetime import datetime, timedelta ...@@ -3,7 +3,6 @@ from datetime import datetime, timedelta
import copy import copy
import json import json
from django.conf import settings
from django.test import TestCase, override_settings from django.test import TestCase, override_settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
...@@ -371,7 +370,7 @@ class TestReports(TestCase): ...@@ -371,7 +370,7 @@ class TestReports(TestCase):
Environment.objects.create(name='Dual Core', cpu='Core 2 Duo 8200') Environment.objects.create(name='Dual Core', cpu='Core 2 Duo 8200')
self.data = { self.data = {
'commitid': 'abcd1', 'commitid': 'abcd1',
'branch': settings.DEF_BRANCH, 'branch': 'master',
'project': 'MyProject', 'project': 'MyProject',
'executable': 'myexe O3 64bits', 'executable': 'myexe O3 64bits',
'benchmark': 'float', 'benchmark': 'float',
......
...@@ -272,13 +272,19 @@ def gettimelinedata(request): ...@@ -272,13 +272,19 @@ def gettimelinedata(request):
} }
# Temporary # Temporary
trunks = [] trunks = []
if Branch.objects.filter(name=settings.DEF_BRANCH): for proj in Project.objects.filter(track=True):
trunks.append(settings.DEF_BRANCH) try:
default_branch = Branch.objects.get(
project=proj, name=proj.default_branch)
except Branch.DoesNotExist:
continue
else:
trunks.append(default_branch)
# For now, we'll only work with trunk branches # For now, we'll only work with trunk branches
append = False append = False
for branch in trunks: for branch in trunks:
append = False append = False
timeline['branches'][branch] = {} timeline['branches'][branch.name] = {}
for executable in executables: for executable in executables:
resultquery = Result.objects.filter( resultquery = Result.objects.filter(
benchmark=bench benchmark=bench
...@@ -287,7 +293,7 @@ def gettimelinedata(request): ...@@ -287,7 +293,7 @@ def gettimelinedata(request):
).filter( ).filter(
executable=executable executable=executable
).filter( ).filter(
revision__branch__name=branch revision__branch=branch
).select_related( ).select_related(
"revision" "revision"
).order_by('-revision__date')[:number_of_revs] ).order_by('-revision__date')[:number_of_revs]
...@@ -313,7 +319,7 @@ def gettimelinedata(request): ...@@ -313,7 +319,7 @@ def gettimelinedata(request):
[ [
res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'), res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'),
res.value, val_max, q3, q1, val_min, res.value, val_max, q3, q1, val_min,
res.revision.get_short_commitid(), res.revision.tag, branch res.revision.get_short_commitid(), res.revision.tag, branch.name
] ]
) )
else: else:
...@@ -324,11 +330,12 @@ def gettimelinedata(request): ...@@ -324,11 +330,12 @@ def gettimelinedata(request):
[ [
res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'), res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'),
res.value, std_dev, res.value, std_dev,
res.revision.get_short_commitid(), res.revision.tag, branch res.revision.get_short_commitid(), res.revision.tag, branch.name
] ]
) )
timeline['branches'][branch][executable] = results timeline['branches'][branch.name][executable] = results
append = True append = True
if baselinerev is not None and append: if baselinerev is not None and append:
try: try:
baselinevalue = Result.objects.get( baselinevalue = Result.objects.get(
...@@ -343,9 +350,9 @@ def gettimelinedata(request): ...@@ -343,9 +350,9 @@ def gettimelinedata(request):
# determine start and end revision (x axis) # determine start and end revision (x axis)
# from longest data series # from longest data series
results = [] results = []
for exe in timeline['branches'][branch]: for exe in timeline['branches'][branch.name]:
if len(timeline['branches'][branch][exe]) > len(results): if len(timeline['branches'][branch.name][exe]) > len(results):
results = timeline['branches'][branch][exe] results = timeline['branches'][branch.name][exe]
end = results[0][0] end = results[0][0]
start = results[len(results) - 1][0] start = results[len(results) - 1][0]
timeline['baseline'] = [ timeline['baseline'] = [
...@@ -401,8 +408,8 @@ def timeline(request): ...@@ -401,8 +408,8 @@ def timeline(request):
branch_list.sort() branch_list.sort()
defaultbranch = "" defaultbranch = ""
if settings.DEF_BRANCH in branch_list: if defaultproject.default_branch in branch_list:
defaultbranch = settings.DEF_BRANCH defaultbranch = defaultproject.default_branch
if data.get('bran') in branch_list: if data.get('bran') in branch_list:
defaultbranch = data.get('bran') defaultbranch = data.get('bran')
...@@ -576,7 +583,7 @@ def changes(request): ...@@ -576,7 +583,7 @@ def changes(request):
for proj in Project.objects.filter(track=True): for proj in Project.objects.filter(track=True):
executables[proj] = Executable.objects.filter(project=proj) executables[proj] = Executable.objects.filter(project=proj)
projectlist.append(proj) projectlist.append(proj)
branch = Branch.objects.filter(name=settings.DEF_BRANCH, project=proj) branch = Branch.objects.filter(name=proj.default_branch, project=proj)
revisionlists[proj.name] = list(Revision.objects.filter( revisionlists[proj.name] = list(Revision.objects.filter(
branch=branch branch=branch
).order_by('-date')[:revlimit]) ).order_by('-date')[:revlimit])
...@@ -631,15 +638,11 @@ def reports(request): ...@@ -631,15 +638,11 @@ def reports(request):
context = {} context = {}
context['reports'] = \ context['reports'] = \
Report.objects.filter( Report.objects.order_by('-revision__date')[:10]
revision__branch__name=settings.DEF_BRANCH
).order_by('-revision__date')[:10] context['significant_reports'] = Report.objects.filter(
colorcode__in=('red', 'green')
context['significant_reports'] = \ ).order_by('-revision__date')[:10]
Report.objects.filter(
revision__branch__name=settings.DEF_BRANCH,
colorcode__in=('red', 'green')
).order_by('-revision__date')[:10]
return render_to_response('codespeed/reports.html', context, return render_to_response('codespeed/reports.html', context,
context_instance=RequestContext(request)) context_instance=RequestContext(request))
......
...@@ -3,8 +3,9 @@ from __future__ import absolute_import ...@@ -3,8 +3,9 @@ from __future__ import absolute_import
from django.conf import settings from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from codespeed.models import Executable, Revision, Project, Branch,\ from codespeed.models import (
Environment, Benchmark, Result Executable, Revision, Project, Branch,
Environment, Benchmark, Result)
def get_default_environment(enviros, data, multi=False): def get_default_environment(enviros, data, multi=False):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment