forked from coala/coala-bears
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitCommitBear: Parse remote with giturlparse
This uses an external library for parsing of remotes. Closes coala#2330
- Loading branch information
1 parent
7ede5b7
commit d35238f
Showing
3 changed files
with
9 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
|
@@ -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, | ||
|