How manicminer/gitlab-migrator works
1. What this repository is
- A single-purpose Go CLI for migrating GitLab projects into GitHub repositories.
- It is not a server or library stack; the runtime is a local command-line process that talks to GitLab and GitHub APIs and performs repository migration work.
2. Top-level execution model
- main.go is the entrypoint and likely wires together flag parsing, logging, credential checks, and the migration run.
- The tool supports both one-off migration and repeated/daemon-like execution via -loop, with controlled parallelism via -max-concurrency.
3. Primary orchestration boundary
- project.go is the central orchestration layer for a single project migration.
- It appears to coordinate the end-to-end sequence: inspect source project, prepare destination repository, migrate git history, optionally migrate merge requests, and apply branch renaming/trimming rules.
4. GitLab and GitHub API integration
- The tool depends on both GITLAB_TOKEN and GITHUB_TOKEN, and uses separate domain flags for GitLab self-hosting and GitHub Enterprise.
- The architecture therefore has two external API boundaries:
- GitLab as the source of truth for project metadata, merge requests, users, and branch state.
- GitHub as the destination for repository creation, repository mutation, pull requests, comments, and user lookup.
5. Repository migration flow
- The core data flow is: GitLab project metadata → destination GitHub repository setup → mirrored git repository contents/history → optional PR translation.
- The README indicates a forced mirror push style of synchronization, so the destination repository is treated as a derived copy of the source rather than a hand-edited target.
6. Merge request to pull request translation
- When -migrate-pull-requests is enabled, GitLab merge requests are converted into GitHub pull requests, including closed/merged ones.
- This is not a simple import: closed merge requests are reconstructed by creating temporary branches, pushing them to GitHub, opening/closing PRs, then deleting the temporary branches.
- Open merge requests can also be adapted for branch renaming, especially when changing master to main or another trunk branch name.
7. Search and idempotence support
- search.go likely encapsulates lookup/search behavior used to find matching GitHub artifacts and map GitLab entities to their GitHub equivalents.
- The README says migrated PRs/comments include Markdown headers with original IDs and author metadata, which provides an idempotence boundary: repeated runs can detect already-migrated items and reconcile them instead of duplicating them.
8. Caching layer
- cache.go provides an in-memory, thread-safe cache for high-churn API lookups.
- Cached primitives include GitHub pull requests, GitHub issue search results, GitHub user profiles, and GitLab user profiles.
- This cache exists to reduce API calls during large migrations and especially matters because the tool runs with concurrency.
9. Shared helpers and cross-cutting concerns
- helper.go likely contains shared utility logic used across orchestration, search, and migration flows.
- Cross-cutting features described in the README include logging levels, branch-name transformation, error handling for invalid merge requests, and profile-link enrichment in migrated comments/PR bodies.
10. Concurrency and operational boundaries
- The tool migrates multiple projects in parallel, with the worker count controlled by -max-concurrency.
- Because the bottlenecks are external APIs, concurrency is an optimization layer over the migration pipeline rather than a core data model change.
- The -projects-csv mode suggests a batch-processing path that feeds many project-pairs into the same migration engine.
11. Configuration and inputs
- Runtime behavior is driven almost entirely by CLI flags plus environment variables.
- Key inputs include source/target domains, source project and destination repository, optional CSV batch file, migration toggles, branch rename options, and safety controls like -delete-existing-repos and -trim-branches-on-github.
12. Build and release infrastructure
- This is a Go module (go.mod, go.sum) built as a cross-platform binary.
- .github/workflows/release.yaml indicates automated release packaging through GitHub Actions, which is the main CI/CD infrastructure visible in the repo.
Main entry points: project.go Project flow · search.go Search map · main.go Entry point · helper.go Helpers
Components 14
CLI runtime
Local command-line execution and batch processing
- Entry point · Parses flags, sets up logging, and starts one-off or looped migrations
main.go - Batch input · CSV-driven multi-project migration input
- Worker loop · Repeated execution and controlled concurrency over migration jobs
Migration core
Single-project orchestration and conversion flow
- Project flow · Coordinates end-to-end migration for a single project
project.go - Repo setup · Prepares or replaces the target GitHub repository before content sync
- Mirror sync · Pushes repository history and branch state into GitHub
- PR translation · Converts GitLab merge requests into GitHub pull requests, including closed ones
- Branch rules · Applies trunk renaming and branch trimming behavior during migration
External APIs
GitLab source and GitHub destination boundaries
- GitLab API · Source of project metadata, merge requests, users, and branch state
- GitHub API · Creates and mutates destination repositories and translated pull requests
Shared support
Lookup, caching, and cross-cutting helpers
- Search map · Finds and matches GitHub and GitLab artifacts during migration
search.go - Lookup cache · Thread-safe cache for high-churn API lookups
cache.go - Helpers · Common utilities for branch rules, logging, error handling, and formatting
helper.go
Release CI
Automated build and release pipeline
- Release workflow · Automated build and packaging pipeline for release artifacts
.github/workflows/release.yaml
Connections 24
- Entry point → Worker loop: runs · Main process can execute once or repeatedly with bounded concurrency
- Entry point → Project flow: starts · Entrypoint dispatches the core migration orchestrator
- Entry point → Batch input: reads · Optional batch file feeds multiple project migrations
- Worker loop → Project flow: workers · Parallel workers process project jobs
- Batch input → Worker loop: feeds · Batch rows become migration tasks
- Project flow → GitLab API: inspects · Reads source project metadata, merge requests, and branch state
- Project flow → GitHub API: creates · Creates and updates destination repositories and PRs
- Project flow → Repo setup: prepares · Sets up destination repository before sync
- Project flow → Mirror sync: syncs · Migrates git history and branch contents
- Project flow → PR translation: optional · Translates merge requests into pull requests when enabled
- Project flow → Branch rules: applies · Renaming and branch trimming rules are enforced during migration
- Project flow → Search map: matches · Uses artifact matching to avoid duplicates and map entities
- Project flow → Helpers: uses · Shares formatting, validation, and branch-name utilities
- Search map → Lookup cache: reads/writes · Caches lookup results for repeated API access
- Search map → GitLab API: queries · Looks up GitLab users, projects, and merge request metadata
- Search map → GitHub API: queries · Looks up GitHub pull requests, issues, and users
- PR translation → Search map: dedupes · Uses lookup results to detect already-migrated pull requests and comments
- Repo setup → GitHub API: mutates · Creates, deletes, or reinitializes destination repositories
- Mirror sync → GitLab API: reads · Pulls source repository state
- Mirror sync → GitHub API: pushes · Force-mirrors repository contents to the destination
- PR translation → GitLab API: reads · Reads source merge requests, authors, and statuses
- PR translation → GitHub API: writes · Creates temporary branches and pull requests, then closes or deletes them as needed
- Branch rules → Helpers: uses · Relies on shared branch transformation logic
- Release workflow → Entry point: builds · Release workflow packages the CLI binary