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
6 changed files
with
106 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class RepoListDecoder: | ||
NAME = None | ||
|
||
def convert_format_to_repo_list(self, file_name): | ||
raise NotImplementedError() | ||
|
||
|
||
def get_all_supported_decoders(): | ||
from org_status.decoders.gitman import GitManDecoder | ||
from org_status.decoders.gitshelf import GitShelfDecoder | ||
|
||
return ( | ||
GitManDecoder, | ||
GitShelfDecoder, | ||
) |
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,18 @@ | ||
import yaml | ||
|
||
from org_status.decoders import RepoListDecoder | ||
|
||
|
||
class GitManDecoder(RepoListDecoder): | ||
NAME = 'gitman' | ||
|
||
def convert_format_to_repo_list(self, file_name): | ||
repos = [] | ||
|
||
with open(file_name, 'r') as file: | ||
yml_data = yaml.load(file) | ||
|
||
for repo in yml_data['sources']: | ||
repos.append(repo['name']) | ||
|
||
return repos |
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,18 @@ | ||
import yaml | ||
|
||
from org_status.decoders import RepoListDecoder | ||
|
||
|
||
class GitShelfDecoder(RepoListDecoder): | ||
NAME = 'gitshelf' | ||
|
||
def convert_format_to_repo_list(self, file_name): | ||
repos = [] | ||
|
||
with open(file_name, 'r') as file: | ||
yml_data = yaml.load(file) | ||
|
||
for repo in yml_data['books']: | ||
repos.append(repo['book']) | ||
|
||
return repos |
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,19 @@ | ||
import yaml | ||
from giturlparse import parse | ||
|
||
from encoders import RepoListEncoder | ||
|
||
|
||
class GitShelfEncoder(RepoListEncoder): | ||
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) |
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