forked from coala/community
-
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.
community/git: Obtain org name from git remote
Closes coala#26
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os.path | ||
|
||
from git.config import GitConfigParser | ||
import giturlparse | ||
|
||
REPO_DIR = os.path.join( | ||
os.path.dirname(__file__), | ||
'..', | ||
) | ||
GIT_CONFIG = os.path.join( | ||
REPO_DIR, | ||
'.git', | ||
'config', | ||
) | ||
|
||
_config = None | ||
|
||
|
||
def get_config(): | ||
global _config | ||
if not _config: | ||
_config = GitConfigParser(GIT_CONFIG) | ||
return _config | ||
|
||
def get_remote(): | ||
config = get_config() | ||
|
||
for key in config.sections(): | ||
if key == 'remote "origin"': | ||
return config.items(key) | ||
if key == 'remote "upstream"': | ||
return config.items(key) | ||
else: | ||
raise KeyError | ||
|
||
|
||
def get_remote_url(): | ||
remote = get_remote() | ||
url = remote[0][1] | ||
url = giturlparse.parse(url) | ||
return url | ||
|
||
|
||
def get_remote_owner(): | ||
url = get_remote_url() | ||
return url.owner |
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,3 +1,5 @@ | ||
gitconfigparser | ||
git-url-parse | ||
django<2.0 | ||
django-distill | ||
IGitt | ||
|
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