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

Remove DEF_BRANCH from settings

parent c7ce34e9
......@@ -3,26 +3,28 @@
"pk": 1,
"model": "codespeed.project",
"fields": {
"repo_type": "N",
"repo_type": "G",
"name": "MyProject",
"commit_browsing_url": "",
"repo_user": "",
"track": true,
"repo_pass": "",
"repo_path": ""
"repo_path": "",
"default_branch": "master"
}
},
{
"pk": 2,
"model": "codespeed.project",
"fields": {
"repo_type": "N",
"repo_type": "M",
"name": "Other",
"commit_browsing_url": "",
"repo_user": "",
"track": true,
"repo_pass": "",
"repo_path": ""
"repo_path": "",
"default_branch": "default"
}
},
{
......
......@@ -139,7 +139,7 @@ class Revision(models.Model):
else:
date = self.date.strftime("%b %d, %H:%M")
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
return string
......
......@@ -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_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
# Given as the name of the executable and commitid of the revision
# Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'}
......
......@@ -3,7 +3,6 @@ from datetime import datetime, timedelta
import copy
import json
from django.conf import settings
from django.test import TestCase, override_settings
from django.core.urlresolvers import reverse
......@@ -371,7 +370,7 @@ class TestReports(TestCase):
Environment.objects.create(name='Dual Core', cpu='Core 2 Duo 8200')
self.data = {
'commitid': 'abcd1',
'branch': settings.DEF_BRANCH,
'branch': 'master',
'project': 'MyProject',
'executable': 'myexe O3 64bits',
'benchmark': 'float',
......
......@@ -272,13 +272,19 @@ def gettimelinedata(request):
}
# Temporary
trunks = []
if Branch.objects.filter(name=settings.DEF_BRANCH):
trunks.append(settings.DEF_BRANCH)
for proj in Project.objects.filter(track=True):
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
append = False
for branch in trunks:
append = False
timeline['branches'][branch] = {}
timeline['branches'][branch.name] = {}
for executable in executables:
resultquery = Result.objects.filter(
benchmark=bench
......@@ -287,7 +293,7 @@ def gettimelinedata(request):
).filter(
executable=executable
).filter(
revision__branch__name=branch
revision__branch=branch
).select_related(
"revision"
).order_by('-revision__date')[:number_of_revs]
......@@ -313,7 +319,7 @@ def gettimelinedata(request):
[
res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'),
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:
......@@ -324,11 +330,12 @@ def gettimelinedata(request):
[
res.revision.date.strftime('%Y/%m/%d %H:%M:%S %z'),
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
if baselinerev is not None and append:
try:
baselinevalue = Result.objects.get(
......@@ -343,9 +350,9 @@ def gettimelinedata(request):
# determine start and end revision (x axis)
# from longest data series
results = []
for exe in timeline['branches'][branch]:
if len(timeline['branches'][branch][exe]) > len(results):
results = timeline['branches'][branch][exe]
for exe in timeline['branches'][branch.name]:
if len(timeline['branches'][branch.name][exe]) > len(results):
results = timeline['branches'][branch.name][exe]
end = results[0][0]
start = results[len(results) - 1][0]
timeline['baseline'] = [
......@@ -401,8 +408,8 @@ def timeline(request):
branch_list.sort()
defaultbranch = ""
if settings.DEF_BRANCH in branch_list:
defaultbranch = settings.DEF_BRANCH
if defaultproject.default_branch in branch_list:
defaultbranch = defaultproject.default_branch
if data.get('bran') in branch_list:
defaultbranch = data.get('bran')
......@@ -576,7 +583,7 @@ def changes(request):
for proj in Project.objects.filter(track=True):
executables[proj] = Executable.objects.filter(project=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(
branch=branch
).order_by('-date')[:revlimit])
......@@ -631,15 +638,11 @@ def reports(request):
context = {}
context['reports'] = \
Report.objects.filter(
revision__branch__name=settings.DEF_BRANCH
).order_by('-revision__date')[:10]
context['significant_reports'] = \
Report.objects.filter(
revision__branch__name=settings.DEF_BRANCH,
colorcode__in=('red', 'green')
).order_by('-revision__date')[:10]
Report.objects.order_by('-revision__date')[:10]
context['significant_reports'] = Report.objects.filter(
colorcode__in=('red', 'green')
).order_by('-revision__date')[:10]
return render_to_response('codespeed/reports.html', context,
context_instance=RequestContext(request))
......
......@@ -3,8 +3,9 @@ from __future__ import absolute_import
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from codespeed.models import Executable, Revision, Project, Branch,\
Environment, Benchmark, Result
from codespeed.models import (
Executable, Revision, Project, Branch,
Environment, Benchmark, Result)
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