Skip to content

Commit

Permalink
GitCommitBear: Parse remote with giturlparse
Browse files Browse the repository at this point in the history
This uses an external library for
parsing of remotes.

Closes #2330
  • Loading branch information
shrikrishna authored and gitmate-bot committed Apr 30, 2018
1 parent 7ede5b7 commit d35238f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions bear-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cpplint~=1.3
dennis~=0.9
docutils-ast-writer~=0.1.2
eradicate~=0.1.6
giturlparse~=0.9.1
guess-language-spirit~=0.5.2
html-linter~=0.4.0
isort~=4.2
Expand Down
2 changes: 2 additions & 0 deletions bear-requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ pip_requirements:
version: ~=0.1.2
eradicate:
version: ~=0.1.6
giturlparse:
version: ~=0.9.1
guess-language-spirit:
version: ~=0.5.2
html-linter:
Expand Down
12 changes: 6 additions & 6 deletions bears/vcs/git/GitCommitBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import shutil
import os
import logging
from urllib.parse import urlparse
from contextlib import redirect_stdout

from giturlparse import parse

from coalib.bears.GlobalBear import GlobalBear
from dependency_management.requirements.PipRequirement import PipRequirement
from coala_utils.ContextManagers import change_directory
Expand All @@ -17,7 +18,8 @@

class GitCommitBear(GlobalBear):
LANGUAGES = {'Git'}
REQUIREMENTS = {PipRequirement('nltk', '3.2')}
REQUIREMENTS = {PipRequirement('nltk', '3.2'),
PipRequirement('giturlparse', '0.9.1')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
LICENSE = 'AGPL-3.0'
Expand Down Expand Up @@ -96,10 +98,8 @@ def get_host_from_remotes():
return None

url = remotes[0]
if 'git@' in url:
netloc = re.findall(r'@(\S+):', url)[0]
else:
netloc = urlparse(url)[1]
parsed_url = parse(url)
netloc = parsed_url.host
return netloc.split('.')[0]

def run(self,
Expand Down

0 comments on commit d35238f

Please sign in to comment.