forked from ksdme/org-status
-
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.
Add gitshelf as a format and fetch certain repos
This adds support for gitshelf as a format for a list of repositories. This also adds support for fetching only repos that are listed in a list of repositories, as specified by --import-repos and --format. Closes ksdme#6 and ksdme#29
- Loading branch information
Showing
8 changed files
with
188 additions
and
90 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class RepoListFormatter: | ||
NAME = None | ||
|
||
def convert_repo_list_to_format(self, repos): | ||
raise NotImplementedError() | ||
|
||
|
||
def get_all_supported_formatters(): | ||
from org_status.formatters.gitman import GitManFormatter | ||
from org_status.formatters.gitshelf import GitShelfFormatter | ||
|
||
return ( | ||
GitManFormatter, | ||
GitShelfFormatter, | ||
) |
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,32 @@ | ||
import yaml | ||
from giturlparse import parse | ||
|
||
from org_status.formatters import RepoListFormatter | ||
|
||
|
||
class GitManFormatter(RepoListFormatter): | ||
NAME = 'gitman' | ||
|
||
def convert_repo_list_to_format(self, repos): | ||
yml_data = {'sources': []} | ||
|
||
for repo in repos: | ||
name = parse(repo.web_url).repo | ||
yml_data['sources'].append({'name': name, | ||
'repo': repo.web_url, | ||
'rev': 'master'}) | ||
|
||
return yaml.dump(yml_data, default_flow_style=False) | ||
|
||
def convert_format_to_repo_list(self, file_name): | ||
repos = [] | ||
|
||
try: | ||
with open(file_name, 'r') as file: | ||
yml_data = yaml.load(file) | ||
|
||
for repo in yml_data['sources']: | ||
repos.append([repo['name'], repo['repo']]) | ||
return repos | ||
except FileNotFoundError: | ||
print(f'unable to find file {file_name}') |
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,32 @@ | ||
import yaml | ||
from giturlparse import parse | ||
|
||
from org_status.formatters import RepoListFormatter | ||
|
||
|
||
class GitShelfFormatter(RepoListFormatter): | ||
NAME = 'gitshelf' | ||
|
||
def convert_repo_list_to_format(self, repos): | ||
yml_data = {'books': []} | ||
|
||
for repo in repos: | ||
name = parse(repo.web_url).repo | ||
yml_data['books'].append({'book': name, | ||
'git': repo.web_url, | ||
'branch': 'master'}) | ||
|
||
return yaml.dump(yml_data, default_flow_style=False) | ||
|
||
def convert_format_to_repo_list(self, file_name): | ||
repos = [] | ||
|
||
try: | ||
with open(file_name, 'r') as file: | ||
yml_data = yaml.load(file) | ||
|
||
for repo in yml_data['books']: | ||
repos.append([repo['book'], repo['git']]) | ||
return repos | ||
except FileNotFoundError: | ||
print(f'unable to find file {file_name}') |
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