Skip to content

Phase 7: BBS API client + all bbs2gh commands (Go port)#1538

Draft
offbyone wants to merge 4 commits intoo1/golang-port/6from
o1/golang-port/7
Draft

Phase 7: BBS API client + all bbs2gh commands (Go port)#1538
offbyone wants to merge 4 commits intoo1/golang-port/6from
o1/golang-port/7

Conversation

@offbyone
Copy link
Copy Markdown
Contributor

@offbyone offbyone commented Apr 1, 2026

Complete port of all bbs2gh functionality from C# to Go. The bbs2gh binary now has full feature parity with 11 commands (3 BBS-specific + 8 shared). This completes the Go port of all application code — all three binaries (gei, ado2gh, bbs2gh) are now fully implemented.

  • BBS REST API client (pkg/bbs/) with project/repo listing, export start/poll, PR listing, isLastPage/nextPageStart pagination

  • SSH (SFTP) archive downloader using golang.org/x/crypto/ssh + github.com/pkg/sftp, with progress logging

  • SMB archive downloader using github.com/hirochachacha/go-smb2, connect → login → mount → read with cleanup

  • migrate-repo — 5-phase handler (preflight → generate archive → download via SSH/SMB → upload to Azure/AWS/GitHub → import via migration API)

  • generate-script — PowerShell script generation iterating projects → repos, with SSH/SMB/AWS/Azure/GitHub storage options

  • inventory-report — generates projects.csv and repos.csv with project count, repo count, and PR counts per repo

  • 8 shared commands via internal/sharedcmd/

  • All tests passing, 0 lint issues

  • All Go application code is now complete — gei (13), ado2gh (19), bbs2gh (11) = 43 commands total

  • 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)


PR Stack (Go port)

offbyone added 4 commits April 1, 2026 08:58
Add SSH (SFTP) and SMB archive download capabilities to the BBS package.
These downloaders are used by bbs2gh migrate-repo to download Bitbucket
Server export archives before uploading them for GitHub import.

SSH downloader:
- Uses golang.org/x/crypto/ssh + github.com/pkg/sftp
- sftpClient interface (Stat/Open/Close) for testability
- Progress logging with rate-limited output
- UserError with --bbs-shared-home hint when using default Linux path

SMB downloader:
- Uses github.com/hirochachacha/go-smb2
- smbConnector + smbShare interfaces for testability
- Connect → Login → Mount → Read loop with cleanup
- UserError with --bbs-shared-home hint when using default Windows path

Shared infrastructure (archive.go):
- Constants: ExportArchiveSourceDirectory, DefaultTargetDirectory,
  DefaultBbsSharedHomeDirectory{Linux,Windows}
- Path helpers: ExportArchiveFileName, SourceExportArchiveAbsolutePath
- fileSystem interface + osFileSystem for testable file operations
- progressLogger with mutex-protected rate limiting
- copyWithProgress shared copy loop
- logFriendlySize and percentage formatters

New files: archive.go, ssh_downloader.go, sftp_client.go,
ssh_downloader_test.go, smb_downloader.go, smb_client.go,
smb_downloader_test.go

15 new tests (6 SSH + 9 SMB), all passing. 0 lint issues.
Port the bbs2gh migrate-repo command from C# to Go with full feature parity:
- 5-phase handler: preflight checks, generate archive (BBS export + poll),
  download archive (SSH/SMB), upload archive (Azure/AWS/GitHub storage),
  import archive (start migration + poll)
- Consumer-defined interfaces for all external dependencies (GitHub API,
  BBS API, archive downloader/uploader, filesystem, env provider)
- Two-constructor pattern: newMigrateRepoCmd (testable) + newMigrateRepoCmdLive
  (production wiring with real SSH/SMB downloaders, Azure/AWS uploaders)
- Comprehensive validation matching C# MigrateRepoCommandArgs: source
  mutual exclusion, SSH/SMB bidirectional pairing, AWS credential checks,
  storage conflict detection, archive-path existence, bbs-shared-home check
- 35+ tests ported from C# MigrateRepoCommandHandlerTests and
  MigrateRepoCommandArgsTests
- awsLogAdapter bridges logger.Logger.Info -> awsStorage.ProgressLogger.LogInfo
- Added env.SmbPassword() and filesystem.OpenRead()/DeleteIfExists() helpers
- 0 lint issues (gocyclo fixed via helper extraction)
Port the bbs2gh generate-script command from C# to Go, generating
PowerShell migration scripts for Bitbucket Server to GitHub migrations.

Implementation:
- generateScriptBbsAPI interface with GetProjects/GetRepos methods
- bbsGenerateScriptArgs struct matching all C# command flags
- newGenerateScriptCmd (testable) and newGenerateScriptCmdLive (production)
- genScriptBbsClientAdapter bridging bbs.Client to consumer-defined interface
- runBbsGenerateScript with validation matching C# (no-ssl-verify, AWS+GH storage conflicts)
- generateBbsScript iterating projects/repos with optional --bbs-project filter
- bbsMigrateRepoScript building per-repo gh bbs2gh migrate-repo commands
- Extracted bbsWriteTargetOptions, bbsWriteSSHOptions, bbsWriteSMBOptions,
  bbsWriteTrailingFlags to keep cyclomatic complexity under threshold
- BBS-specific validation constants (bbsValidateBBSUsername, bbsValidateBBSPassword,
  bbsValidateSMBPassword) matching C# inline strings exactly
- bbsAppendLine/bbsAppendBlankLine helpers replicating C# AppendLine semantics
  (skip null/whitespace content, always append blank lines)
- bbsReplaceInvalidCharactersWithDash for GitHub repo name sanitization

Tests: All 22 C# GenerateScriptCommandHandlerTests ported and passing.
Wired into cmd/bbs2gh/main.go via newGenerateScriptCmdLive().
- inventory-report: generates projects.csv and repos.csv from BBS server
  with project count, repo count, and PR counts per repo
- Wired all 8 shared commands into bbs2gh: wait-for-migration,
  abort-migration, download-logs, generate-mannequin-csv,
  reclaim-mannequin, grant-migrator-role, revoke-migrator-role,
  create-team
- bbs2gh now has 11 commands total (matching C# parity)
- All tests pass, zero lint issues
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