Repository navigation
Mapping Guide
The mapping.json file defines which GitHub organizations and repositories are synced to which GitLab groups and projects. hub2lab supports two modes: explicit mapping (list every repo) and auto-sync (sync all repos).
By default, hub2lab looks for mapping.json in the current working directory. Override with the MAPPING_FILE environment variable.
{
"mappings": [
{
"github_org": "my-org",
"gitlab_group": "my-group",
"repos": {
"repo-a": "repo-a-mirror",
"repo-b": "repo-b"
}
}
]
}Use this when repo names differ between sides, or you only want a subset of repos synced.
{
"mappings": [
{
"github_org": "acme-corp",
"gitlab_group": "acme-mirrors",
"repos": {
"frontend": "frontend-app",
"backend": "backend-service",
"docs": "documentation"
}
}
]
}Each key under repos is a GitHub repo name; the value is the corresponding GitLab project name. Only repos listed in repos will be synced.
Omit repos entirely. Any repo in the GitHub org is synced to a same-named GitLab project (and vice versa).
{
"mappings": [
{
"github_org": "oss-town",
"gitlab_group": "oss-mirrors"
}
]
}Useful when you have many repos and names match on both sides.
You can have multiple mapping entries in a single file, mixing both modes:
{
"mappings": [
{
"github_org": "acme-corp",
"gitlab_group": "acme",
"repos": {
"backend": "backend-service"
}
},
{
"github_org": "oss-town",
"gitlab_group": "oss-mirrors"
}
]
}When a webhook arrives from GitHub, hub2lab:
- Extracts the organization and repo name from the payload
- Scans all mappings for a matching
github_org - If the mapping has a
reposdict, looks up the GitHub repo name as a key - If the key exists (or
reposis absent), uses the corresponding GitLab project name - Performs the sync action
The same process runs in reverse for GitLab webhooks.
Source: src/config/mapper.ts
-
resolveGitHubToGitLab()— finds the GitLab project name for a given GitHub org + repo -
resolveGitLabToGitHub()— finds the GitHub org + repo for a given GitLab group + project -
findGroupByOrg()— returns the GitLab group for a GitHub org -
findOrgByGroup()— returns the GitHub org for a GitLab group
Repo not in mapping: If a GitHub repo doesn't match any mapping entry (and auto-sync isn't active for that org), the event is silently skipped with a log message.
Mapping not found from GitLab: If a GitLab project doesn't reverse-map to any GitHub repo, the event is skipped. Note: hub2lab only maps group-level GitLab projects; personal namespace projects are not supported.
Multiple orgs per instance: You can list multiple org→group pairs in mappings[]. Each pair is independent.