default to only looking at openstack/* projects
This commit is contained in:
parent
053acaab52
commit
f8ff564b5e
|
@ -64,10 +64,24 @@ class Discover(Command):
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(Discover, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'--organization', '--org', '-o',
|
||||||
|
action='append',
|
||||||
|
default=[],
|
||||||
|
help=('organization directory names under the project root, '
|
||||||
|
'for example: "stackforge", defaults to "openstack"'),
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
session = self.app.get_db_session()
|
session = self.app.get_db_session()
|
||||||
pm = project.ProjectManager(session)
|
pm = project.ProjectManager(session)
|
||||||
for project_name in project.discover(self.app.options.repo_root):
|
orgs = parsed_args.organization
|
||||||
|
if not orgs:
|
||||||
|
orgs = ['openstack']
|
||||||
|
for project_name in project.discover(self.app.options.repo_root, orgs):
|
||||||
full_path = os.path.join(self.app.options.repo_root,
|
full_path = os.path.join(self.app.options.repo_root,
|
||||||
project_name)
|
project_name)
|
||||||
pm.add_or_update(project_name, full_path)
|
pm.add_or_update(project_name, full_path)
|
||||||
|
|
|
@ -16,15 +16,13 @@ from aeromancer import utils
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def discover(repo_root):
|
def discover(repo_root, organizations):
|
||||||
"""Discover project-like directories under the repository root"""
|
"""Discover project-like directories under the repository root"""
|
||||||
|
glob_patterns = ['%s/*' % o for o in organizations]
|
||||||
with utils.working_dir(repo_root):
|
with utils.working_dir(repo_root):
|
||||||
return itertools.ifilter(
|
return itertools.ifilter(
|
||||||
lambda x: os.path.isdir(os.path.join(repo_root, x)),
|
lambda x: os.path.isdir(os.path.join(repo_root, x)),
|
||||||
itertools.chain(
|
itertools.chain(*(glob.glob(g) for g in glob_patterns))
|
||||||
glob.glob('openstack*/*'),
|
|
||||||
glob.glob('stackforge/*'),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _find_files_in_project(path):
|
def _find_files_in_project(path):
|
||||||
|
|
Loading…
Reference in New Issue