Skip to content

Commit

Permalink
Merge pull request #47 from schinckel/mercurial-support
Browse files Browse the repository at this point in the history
Support mercurial repositories.
  • Loading branch information
z4r committed Feb 29, 2016
2 parents 03eea6c + fdb5dce commit 8b078aa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coveralls/__init__.py
Expand Up @@ -77,7 +77,7 @@ def parse_args():

def wear(args=None):
from coveralls.control import coveralls
from coveralls.repository import gitrepo
from coveralls.repository import repo
from coveralls.api import post
import logging
logging.basicConfig(level=logging.INFO)
Expand All @@ -90,7 +90,7 @@ def wear(args=None):
repo_token=args.repo_token,
service_job_id=args.service_job_id,
service_name=args.service_name,
git=gitrepo(args.base_dir) if not args.nogit else {},
git=repo(args.base_dir) if not args.nogit else {},
source_files=coverage.coveralls(args.base_dir, ignore_errors=args.ignore_errors, merge_file=args.merge_file),
parallel=args.parallel,
)
Expand Down
36 changes: 36 additions & 0 deletions coveralls/repository.py
Expand Up @@ -22,3 +22,39 @@ def gitrepo(root):
"branch": branch,
"remotes": [{'name': remote[0], 'url': remote[1]} for remote in remotes]
}


HGLOG = """{node}
{author|person}
{author|email}
{author|person}
{author|email}
{desc}"""


def hgrepo(root):
hglog = sh.hg('log', '-l', '1', template=HGLOG).split('\n', 5)
branch = (os.environ.get('CIRCLE_BRANCH') or
os.environ.get('TRAVIS_BRANCH', sh.hg('branch').strip()))
remotes = [x.split(' = ') for x in sh.hg('paths')]
return {
'head': {
'id': hglog[0],
'author_name': hglog[1],
'author_email': hglog[2],
'committer_name': hglog[3],
'committer_email': hglog[4],
'message': hglog[5].strip(),
},
'branch': branch,
'remotes': [{
'name': remote[0], 'url': remote[1]
} for remote in remotes]
}


def repo(root):
if '.git' in os.listdir(root):
return gitrepo(root)
if '.hg' in os.listdir(root):
return hgrepo(root)

0 comments on commit 8b078aa

Please sign in to comment.