Skip to content

Commit 4dfeab2

Browse files
committed
Use variables for the repo type switch
1 parent 9157b18 commit 4dfeab2

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

codespeed/commits/logs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
def get_logs(rev, startrev, update=False):
1010
logs = []
11-
12-
if rev.branch.project.repo_type == 'S':
11+
project = rev.branch.project
12+
if project.repo_type == project.SUBVERSION:
1313
from .subversion import getlogs, updaterepo
14-
elif rev.branch.project.repo_type == 'M':
14+
elif project.repo_type == project.MERCURIAL:
1515
from .mercurial import getlogs, updaterepo
16-
elif rev.branch.project.repo_type == 'G':
16+
elif project.repo_type == project.GIT:
1717
from .git import getlogs, updaterepo
18-
elif rev.branch.project.repo_type == 'H':
18+
elif project.repo_type == project.GITHUB:
1919
from .github import getlogs, updaterepo
2020
else:
21-
if rev.branch.project.repo_type not in ("N", ""):
21+
if project.repo_type not in (project.NO_LOGS, ""):
2222
logger.warning("Don't know how to retrieve logs from %s project",
23-
rev.branch.project.get_repo_type_display())
23+
project.get_repo_type_display())
2424
return logs
2525

2626
if update:

codespeed/models.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@
1313

1414

1515
class Project(models.Model):
16+
NO_LOGS = 'N'
17+
GIT = 'G'
18+
GITHUB = 'H'
19+
MERCURIAL = 'M'
20+
SUBVERSION = 'S'
1621
REPO_TYPES = (
17-
('N', 'none'),
18-
('G', 'git'),
19-
('H', 'Github.com'),
20-
('M', 'mercurial'),
21-
('S', 'subversion'),
22+
(NO_LOGS, 'none'),
23+
(GIT, 'git'),
24+
(GITHUB, 'Github.com'),
25+
(MERCURIAL, 'mercurial'),
26+
(SUBVERSION, 'subversion'),
2227
)
2328

2429
name = models.CharField(unique=True, max_length=30)
2530
repo_type = models.CharField(
26-
"Repository type", max_length=1, choices=REPO_TYPES, default='N')
31+
"Repository type", max_length=1, choices=REPO_TYPES, default=NO_LOGS)
2732
repo_path = models.CharField("Repository URL", blank=True, max_length=200)
2833
repo_user = models.CharField("Repository username",
2934
blank=True, max_length=100)

0 commit comments

Comments
 (0)