Skip to content

Phase 5: gei migrate-repo, migrate-org, alert migration commands (Go port)#1536

Draft
offbyone wants to merge 2 commits intoo1/golang-port/4from
o1/golang-port/5
Draft

Phase 5: gei migrate-repo, migrate-org, alert migration commands (Go port)#1536
offbyone wants to merge 2 commits intoo1/golang-port/4from
o1/golang-port/5

Conversation

@offbyone
Copy link
Copy Markdown
Contributor

@offbyone offbyone commented Mar 31, 2026

Implements the three main gei migration commands: migrate-repo, migrate-org, and the alert migration commands.

  • migrate-repo — the most complex command (~1142 lines), supporting GitHub.com→GitHub.com, GHES→GitHub.com (via Azure/AWS/GitHub-owned storage), local archive paths, queue-only mode, and full migration with status polling

  • migrate-org — org-level migration with queue-only and full migration modes, per-repo progress reporting

  • migrate-secret-alerts — dictionary matching by (SecretType, Secret), location comparison, resolution comment truncation to 270 chars

  • migrate-code-scanning — SARIF download/upload with gzip+base64 encoding, processing status polling, alert matching by RuleId + instance equality

  • ~11 new GitHub REST API methods for secret scanning and code scanning operations

  • 83+ tests across all new packages, all passing with -race

  • Did you write/update appropriate tests

  • Release notes updated (if appropriate) — not user-facing yet (parallel Go port)

  • Appropriate logging output

  • Issue linked — tracking via PR stack

  • Docs updated (or issue created) — internal packages, covered by godoc

  • New package licenses are added to ThirdPartyNotices.txt (if applicable) — no new deps


PR Stack (Go port)

offbyone added 2 commits April 1, 2026 08:58
Port the most complex GEI command — migrate-repo — supporting GitHub-to-GitHub,
GHES-to-GitHub, and local archive migration paths.

New files:
- cmd/gei/migrate_repo.go (1142 lines): Full migrate-repo command with validation,
  archive generation/download/upload, migration queueing, and optional wait-for-migration.
  Supports --queue-only, --target-repo-visibility, --skip-releases, --lock-source-repo,
  --keep-archive, local archive paths (--git-archive-path/--metadata-archive-path),
  and GHES blob credential detection.
- cmd/gei/migrate_repo_test.go (947 lines, 36 tests): Validation tests, happy-path
  flows for GHES/GHEC/local archives, error handling, queue-only mode, permissions
  error formatting, archive polling, and download retry on expired URL.

Modified files:
- pkg/github/client.go: 5 new methods — DoesRepoExist, StartGitArchiveGeneration,
  StartMetadataArchiveGeneration, GetArchiveMigrationStatus, GetArchiveMigrationUrl
  (302-redirect capture via no-redirect HTTP client).
- pkg/github/client_test.go: 12 new tests for the archive API methods.
- cmd/gei/main.go: Wire newMigrateRepoCmdLive() into root command.
- cmd/gei/generate_script.go: Export MigrateRepoCommand for reuse.
- .golangci.yml: Bump gocyclo threshold and add funlen exclusion for test files.
migrate-org command (Task 18):
- cmd/gei/migrate_org.go: 274-line command with queue-only and full migration modes
- Polls org migration status using existing pkg/migration/status.go helpers
- Iterates repo migrations within org migration, reporting per-repo progress
- 13 tests covering validation, queue-only, full migration, failure, token
  resolution, URL escaping, context cancellation, multi-state polling
- Consumer-defined interfaces: orgMigrator, migrateOrgEnvProvider

Alert migration commands (Task 19):
- New models in pkg/github/models.go: SecretScanningAlert, CodeScanningAlert,
  CodeScanningAnalysis, SarifProcessingStatus, and related types
- ~11 new REST API methods in pkg/github/client.go for secret scanning and
  code scanning alert operations (get/update alerts, SARIF upload/status)
- pkg/alerts/secret_scanning.go: Dictionary matching by (SecretType, Secret),
  location comparison, resolution comment truncation to 270 chars
- pkg/alerts/code_scanning.go: SARIF download/upload with gzip+base64,
  processing status polling, alert matching by RuleId + instance equality
- cmd/gei/migrate_secret_alerts.go + tests (11 tests)
- cmd/gei/migrate_code_scanning.go + tests (11 tests)
- All commands wired into cmd/gei/main.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant