Skip to content

Commit

Permalink
Using REGEXP in projects instead of glob
Browse files Browse the repository at this point in the history
Now it is possible to use full regular expressions in project
name definitions.
  • Loading branch information
wiro committed Jun 2, 2019
1 parent 826f281 commit c693476
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions gitlab-project-export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import yaml
from datetime import date
import requests
import re
# Find our libs
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from lib import config, gitlab
Expand Down Expand Up @@ -51,15 +52,19 @@

# Export each project
export_projects = []
for project in c.config["gitlab"]["projects"]:
if '*' in project:
projects = gitlab.project_list(project)
if projects:
export_projects += projects
else:
print("Unable to get projects for %s" % (project), file=sys.stderr)
else:
export_projects.append(project)

# Get All member projects from gitlab
projects = gitlab.project_list()
if not projects:
print("Unable to get projects for your account", file=sys.stderr)
sys.exit(1)

# Check projects against config
# Create export_projects array
for project_pattern in c.config["gitlab"]["projects"]:
for gitlabProject in projects:
if re.match(project_pattern, gitlabProject):
export_projects.append(gitlabProject)

if args.debug:
print("Projects to export: " + str(export_projects))
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __api_import_status(self, project_url):
project_url + "/import",
headers=self.headers)

def project_list(self, path_glob):
def project_list(self, path_glob=""):
''' List projects based on glob path '''
urlpath = '/projects?simple=True&membership=True&per_page=50'
page = 1
Expand Down

0 comments on commit c693476

Please sign in to comment.