Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ This tap:
- API URL for your GitLab account. If you are using the public gitlab.com this will be `https://gitlab.com/api/v3`
- Groups to track (space separated)
- Projects to track (space separated)
- Recurse through subgroups (boolean). If true, all subgroups will be tracked of the groups specified in the Groups setting will be tracked

Notes:
- either groups or projects need to be provided
- filling in 'groups' but leaving 'projects' empty will sync all group projects.
- filling in 'groups' and setting 'recurse' to true will sync all group projects and all subgroups projects.
- filling in 'projects' but leaving 'groups' empty will sync selected projects.
- filling in 'groups' and 'groups' will sync selected projects of those groups.

```json
{"api_url": "https://gitlab.com/api/v3",
"private_token": "your-access-token",
"groups": "myorg mygroup",
"groups": "myorg mygroup",
"recurse_groups": false,
"projects": "myorg/repo-a myorg/repo-b",
"start_date": "2018-01-01T00:00:00Z"}
```
Expand Down
14 changes: 14 additions & 0 deletions tap_gitlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'api_url': "https://gitlab.com/api/v3",
'private_token': None,
'start_date': None,
'recurse_groups': False,
'groups': ''
}
STATE = {}
Expand Down Expand Up @@ -57,6 +58,11 @@ def load_schema(entity):
'schema': load_schema('milestones'),
'key_properties': ['id'],
},
'group_subgroups': {
'url': '/groups/{}/subgroups',
'schema': load_schema('groups'),
'key_properties': ['id'],
},
'users': {
'url': '/projects/{}/users',
'schema': load_schema('users'),
Expand Down Expand Up @@ -211,6 +217,14 @@ def sync_group(gid, pids):
if project['id']:
pids.append(project['id'])

if CONFIG['recurse_groups'] is True:
group_subgroups_url = get_url("group_subgroups", id=gid)
print(group_subgroups_url)

for group in gen_request(group_subgroups_url):
if group["name"]:
sync_group(str(group["full_path"].replace("/", "%2F")), [])

for pid in pids:
sync_project(pid)

Expand Down