forked from tobami/codespeed
-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
4 changed files
with
131 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .logs import get_logs | ||
from .logs import get_logs, get_commit_date |
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 |
---|---|---|
@@ -1,35 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
import datetime | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_logs(rev, startrev, update=False): | ||
logs = [] | ||
project = rev.branch.project | ||
def get_scm(project): | ||
if project.repo_type == project.SUBVERSION: | ||
from .subversion import getlogs, updaterepo | ||
elif project.repo_type == project.MERCURIAL: | ||
from .mercurial import getlogs, updaterepo | ||
from .mercurial import Mercurial | ||
return Mercurial(project) | ||
elif project.repo_type == project.GIT: | ||
from .git import getlogs, updaterepo | ||
elif project.repo_type == project.GITHUB: | ||
from .github import getlogs, updaterepo | ||
else: | ||
return None | ||
|
||
|
||
def get_logs(rev, startrev, update=False): | ||
logs = [] | ||
project = rev.branch.project | ||
|
||
scm = get_scm(project) | ||
if scm is None: | ||
if project.repo_type not in (project.NO_LOGS, ""): | ||
logger.warning("Don't know how to retrieve logs from %s project", | ||
project.get_repo_type_display()) | ||
return logs | ||
|
||
if update: | ||
updaterepo(rev.branch.project) | ||
scm.update_repo(project) | ||
|
||
logs = getlogs(rev, startrev) | ||
logs = scm.get_logs(rev, startrev) | ||
|
||
# Remove last log because the startrev log shouldn't be shown | ||
if len(logs) > 1 and logs[-1].get('commitid') == startrev.commitid: | ||
logs.pop() | ||
|
||
return logs | ||
|
||
|
||
def _get_commit_date(project, commit_id): | ||
scm = get_scm(project) | ||
if scm is None: | ||
return None | ||
|
||
return scm.get_commit_date(commit_id) | ||
|
||
def get_commit_date(project, commit_id): | ||
date = _get_commit_date(project, commit_id) | ||
if date is not None: | ||
return date | ||
|
||
if project.repo_type not in (project.NO_LOGS, ""): | ||
logger.warning("Failed to get the date of the commit %r of project %s", | ||
commit_id, project.get_repo_type_display()) | ||
return datetime.datetime.today() |
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