Thank you for your interest in contributing to git-wt! This document provides guidelines and instructions for contributing.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/git-wt.git cd git-wt - Add the upstream repository:
git remote add upstream https://github.com/shogs/git-wt.git
- Go 1.21 or later
- Git
- Make (optional, but recommended)
# Build for current platform
go build -o git-wt .
# Or use Make
make build# Run all tests
go test -v ./...
# Run tests with coverage
go test -v -cover ./...Before submitting a PR, ensure your code passes all checks:
# Format code
go fmt ./...
# Lint code
go vet ./...
# Build for all platforms
make build-all-
Create a new branch:
git checkout -b feature/your-feature-name
-
Make your changes following the coding guidelines below
-
Add tests for new functionality
-
Commit your changes:
git commit -m "Add feature: description" -
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request
- Follow the official Go Code Review Comments
- Use
go fmtto format your code - Write clear, descriptive variable and function names
- Add comments for exported functions and complex logic
- Keep functions small and focused
- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- Start with a capital letter
- Keep the first line under 72 characters
- Reference issues and PRs when relevant
Examples:
Add support for custom worktree directories
Fix crash when removing non-existent worktree
Update README with installation instructions
- Place new commands in
cmd/directory - Follow existing patterns for command structure
- Keep utility functions in appropriate helper files:
cmd/git.go- Git operationscmd/config.go- Configuration handlingcmd/session.go- Session managementcmd/actions.go- New/remove actions
When adding a new command:
- Create a new file in
cmd/(e.g.,cmd/newcommand.go) - Follow this structure:
package cmd
import (
"github.com/spf13/cobra"
)
var newCmd = &cobra.Command{
Use: "new-command [args]",
Short: "Short description",
Long: `Longer description of what the command does.`,
RunE: func(cmd *cobra.Command, args []string) error {
// Command implementation
return nil
},
}
func init() {
rootCmd.AddCommand(newCmd)
// Add flags if needed
}- Add tests in
cmd/newcommand_test.go - Update README.md with usage examples
- Update CHANGELOG.md
Write unit tests for new functionality:
func TestNewFeature(t *testing.T) {
// Test implementation
}For commands that interact with git, consider adding integration tests that:
- Create a temporary git repository
- Test the command in a realistic scenario
- Clean up after themselves
- Update README.md with new features
- Add examples for new commands
- Update configuration documentation if adding new config options
- Add comments to exported functions
- Ensure all tests pass
- Update documentation as needed
- Add a description of your changes
- Link any related issues
- Wait for review from maintainers
## Description
Brief description of what this PR does
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
Describe how you tested your changes
## Checklist
- [ ] Tests pass locally
- [ ] Code follows style guidelines
- [ ] Documentation updated
- [ ] No new warningsReleases are automated using GitHub Actions and GoReleaser:
- Update version in relevant files
- Update CHANGELOG.md
- Create and push a tag:
git tag -a v1.1.0 -m "Release version 1.1.0" git push origin v1.1.0 - GitHub Actions will automatically build and create a release
If you have questions, feel free to:
- Open an issue
- Start a discussion
- Reach out to maintainers
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Assume good intentions
Thank you for contributing to git-wt!