Phase 7: BBS API client + all bbs2gh commands (Go port)#1538
Draft
offbyone wants to merge 4 commits intoo1/golang-port/6from
Draft
Phase 7: BBS API client + all bbs2gh commands (Go port)#1538offbyone wants to merge 4 commits intoo1/golang-port/6from
offbyone wants to merge 4 commits intoo1/golang-port/6from
Conversation
This was referenced Mar 31, 2026
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
bb4e900 to
ccd68f9
Compare
39b5cd4 to
777b69a
Compare
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Complete port of all bbs2gh functionality from C# to Go. The
bbs2ghbinary 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/nextPageStartpaginationSSH (SFTP) archive downloader using
golang.org/x/crypto/ssh+github.com/pkg/sftp, with progress loggingSMB archive downloader using
github.com/hirochachacha/go-smb2, connect → login → mount → read with cleanupmigrate-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 optionsinventory-report— generatesprojects.csvandrepos.csvwith project count, repo count, and PR counts per repo8 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 stackDocs updated (or issue created)— internal packages, covered by godocNew package licenses are added to
ThirdPartyNotices.txt(if applicable)PR Stack (Go port)