Thank you for your interest in contributing to bb, the Bitbucket Cloud CLI! This document provides guidelines and instructions for contributing.
Please read and follow our Code of Conduct to help maintain a welcoming and inclusive community.
- Go 1.21+ - Download and install Go
- Git - For version control
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/bitbucket-cli.git cd bitbucket-cli -
Build the CLI:
go build ./cmd/bb
-
Run tests:
go test ./... -
Run the CLI locally:
./bb --help
bitbucket-cli/
├── cmd/bb/ # Main entry point
│ └── main.go # Application bootstrap
├── internal/
│ ├── api/ # Bitbucket API client
│ ├── cmd/ # Command implementations
│ ├── cmdutil/ # Shared command utilities
│ └── config/ # Configuration handling
├── go.mod
└── go.sum
| Directory | Purpose |
|---|---|
cmd/bb/ |
Main entry point and CLI initialization |
internal/api/ |
Bitbucket Cloud API client and types |
internal/cmd/ |
Individual command implementations (pr, repo, etc.) |
internal/config/ |
Configuration loading, storage, and authentication |
internal/cmdutil/ |
Shared utilities for commands (formatting, prompts, etc.) |
We use Cobra for command management. To add a new command:
-
Create a new file in
internal/cmd/(or appropriate subdirectory):// internal/cmd/mycommand/mycommand.go package mycommand import ( "github.com/spf13/cobra" ) func NewCmdMyCommand() *cobra.Command { cmd := &cobra.Command{ Use: "mycommand", Short: "Brief description of the command", Long: `Longer description explaining the command in detail.`, RunE: func(cmd *cobra.Command, args []string) error { // Command implementation return nil }, } // Add flags cmd.Flags().StringP("flag-name", "f", "", "Flag description") return cmd }
-
Register the command in the parent command or root command.
-
Add tests for your command in a
_test.gofile.
-
Run
gofmton all code before committing:gofmt -w . -
Run
go vetto catch common issues:go vet ./...
- Follow Effective Go guidelines
- Keep functions focused and small
- Use meaningful variable and function names
- Add comments for exported functions and types
- Handle errors explicitly; avoid ignoring them
We recommend using golangci-lint for comprehensive linting:
golangci-lint run- All new features must include tests
- Bug fixes should include regression tests
- Tests should be in
_test.gofiles alongside the code they test
# Run all tests
go test ./...
# Run tests with verbose output
go test -v ./...
# Run tests with coverage
go test -cover ./...
# Run tests for a specific package
go test ./internal/cmd/pr/...func TestMyFunction(t *testing.T) {
// Arrange
input := "test"
// Act
result := MyFunction(input)
// Assert
if result != expected {
t.Errorf("MyFunction(%q) = %q; want %q", input, result, expected)
}
}- Check existing issues and PRs to avoid duplicate work
- For significant changes, open an issue first to discuss the approach
-
Create a feature branch:
git checkout -b feature/your-feature-name # or git checkout -b fix/issue-description -
Make your changes with clear, focused commits
-
Commit message format:
type: short description Longer description if needed. Explain what and why, not how (the code shows how). Fixes #123Types:
feat,fix,docs,refactor,test,choreExamples:
feat: add support for PR templates fix: handle empty repository list gracefully docs: update installation instructions -
Push your branch:
git push origin feature/your-feature-name
-
Open a Pull Request with the following information:
## Description Brief description of the changes. ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update ## Testing Describe how you tested your changes. ## Checklist - [ ] Code follows the project's style guidelines - [ ] Tests added/updated for changes - [ ] Documentation updated if needed - [ ] `go test ./...` passes - [ ] `go vet ./...` reports no issues
- PRs require at least one maintainer approval
- Address review feedback promptly
- Keep PRs focused; split large changes into smaller PRs
When reporting a bug, include:
- bb version: Output of
bb --version - Go version: Output of
go version - Operating system: e.g., macOS 14.0, Ubuntu 22.04
- Steps to reproduce: Clear, numbered steps
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Error messages: Full error output if applicable
When requesting a feature, include:
- Use case: Why do you need this feature?
- Proposed solution: How do you envision it working?
- Alternatives considered: Other approaches you've thought about
-
Update version in relevant files
-
Update CHANGELOG.md with release notes
-
Create a release commit:
git commit -am "chore: release vX.Y.Z" -
Tag the release:
git tag -a vX.Y.Z -m "Release vX.Y.Z" git push origin main --tags -
Create GitHub release with changelog notes
-
Verify release artifacts are built and published correctly
If you have questions about contributing, feel free to:
- Open a Discussion
- Ask in an existing related issue
Thank you for contributing!