Skip to content

Commit

Permalink
Merge pull request #5 from rvojcik/fix_issue2
Browse files Browse the repository at this point in the history
introduce membership option to configuration file #2
  • Loading branch information
rvojcik committed Jun 16, 2020
2 parents 76c8042 + 9ddbcea commit 51d9a32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config.yaml-example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ gitlab:
projects:
- rvojcik/example-project
- rvojcik/group/*
# Membership attribute used when searching for projects
# If you want to export all projects from private gitlab instance
# sse False here. In big shared instances or gitlab.com use True
membership: True
# Wait Between Exports
# How many seconds to wait between projects to export.
# This is due rate-limiting in gitlab.com
Expand Down
8 changes: 7 additions & 1 deletion gitlab-project-export.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
else:
wait_between_exports = 0

# Check if there is membership in config
if 'membership' in c.config["gitlab"]:
membership = c.config["gitlab"]["membership"]
else:
membership = True

# Init gitlab api object
if args.debug:
print("%s, token" % (gitlab_url))
Expand All @@ -61,7 +67,7 @@
export_projects = []

# Get All member projects from gitlab
projects = gitlab.project_list()
projects = gitlab.project_list(membership=str(membership))
if not projects:
print("Unable to get projects for your account", file=sys.stderr)
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions lib/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ 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="", membership="True"):
''' List projects based on glob path '''
urlpath = '/projects?simple=True&membership=True&per_page=50'
urlpath = '/projects?simple=True&membership=%s&per_page=50' % (membership)
page = 1
output = []
if not self.project_array:
Expand Down

0 comments on commit 51d9a32

Please sign in to comment.