Input Files
Project Cleanup requires two input files containing data from the GitLab API: a projects file and a merge requests file. These files must be generated separately before running the cleanup tool.
| The format of these is based on other tooling used at The Open Group. It is the same as the output from the GitLab APIs, except that some extra fields are added. New fields are all prefixed with underscores. |
Overall Structure
Each of the input files has a similar basic structure.
There is a timestamp field that represents the data collection time, and an entries object that stores the data entries.
The entries are indexed by ID for fast lookup once read into memory.
Projects File
The projects file has many extra fields for various project components. This is the predominant file used by the cleanup scripts.
{
"timestamp": "2024-12-24T12:00:00Z",
"entries": {
"123": {
// These fields (and many others not shown) come from /projects/:id
"id": 123,
"name": "my-project",
"path": "my-project",
"name_with_namespace": "My Group / My Project",
"path_with_namespace": "my-group/my-project",
"web_url": "https://gitlab.example.com/my-group/my-project",
"default_branch": "main",
// From /projects/:id/repository/branches
"_branches": [...],
// From /projects/:id/repository/tags
"_tags": [...],
// From /projects/:id/registry/repositories
"_containers": [...],
// From /projects/:id/packages
"_packages": [...],
// From /projects/:id/protected_branches
"_protectedBranches": [...]
}
}
}
Merge Requests File
The merge requests file contains all merge requests across projects in the namespace.
This is pulled in separately simply because existing tooling builds it separately.
The project-cleanup.js script combines the two after loading, creating a _mrs array in each project that has only that project’s MRs.
Structure
{
"timestamp": "2024-12-24T12:00:00Z",
"entries": {
"1001": {
// These fields (and many others not shown) come from /merge_requests
"id": 1001,
"iid": 42,
"project_id": 123,
"source_branch": "feature-branch",
"target_branch": "main",
"state": "merged",
"squash": true,
"sha": "abc123..."
}
}
}