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
8 changed files
with
83 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,4 +102,3 @@ ENV/ | |
|
||
_site/ | ||
/public/ | ||
org_name.txt |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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() | ||
|
||
print(config.sections()) | ||
|
||
has_remote = False | ||
branches = [] | ||
|
||
for key in config.sections(): | ||
if key == 'remote "origin"': | ||
return config.items(key) | ||
elif key == 'remote "upstream"': | ||
return config.items(key) | ||
elif key.startswith('remote'): | ||
has_remote = True | ||
elif key.startswith('branch'): | ||
branches.append(config.items(key)) | ||
|
||
print(branches) | ||
|
||
if has_remote: | ||
raise KeyError('No git remote called "origin" or "upstream"') | ||
|
||
raise KeyError('No git remotes found') | ||
|
||
|
||
def get_remote_url(): | ||
remote = get_remote() | ||
url = remote[0][1] | ||
try: | ||
url = giturlparse.parse(url) | ||
except: | ||
url = giturlparse.parse(url + '.git') | ||
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
This file was deleted.
Oops, something went wrong.
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