# Git Workflow Standards

## Branch Structure
### Main Branches
1. main
   - Production-ready code
   - Tagged releases only
   - Protected branch
   - Requires pull request approval

2. develop
   - Integration branch
   - Source for feature branches
   - Continuous integration testing
   - Pre-release staging

### Supporting Branches
1. feature/*
   - Branch from: develop
   - Merge to: develop
   - Naming: feature/descriptive-name
   - Example: feature/permission-handlers

2. release/*
   - Branch from: develop
   - Merge to: main and develop
   - Naming: release/v1.0.0
   - For version preparation

3. hotfix/*
   - Branch from: main
   - Merge to: main and develop
   - Naming: hotfix/critical-fix
   - For urgent production fixes

## Workflow Procedures
### Initial Setup
1. Clone Repository:
   git clone https://gitea.sigd.net/chaulmark/ChessPrism.git
   cd ChessPrism

2. Create Develop Branch:
   git checkout -b develop
   git push -u origin develop

### Feature Development
1. Create Feature Branch:
   git checkout develop
   git pull origin develop
   git checkout -b feature/your-feature

2. Development Cycle:
   git add .
   git commit -m "type: descriptive message"
   git push -u origin feature/your-feature

3. Complete Feature:
   git checkout develop
   git pull origin develop
   git merge feature/your-feature
   git push origin develop

### Release Process
1. Create Release Branch:
   git checkout develop
   git checkout -b release/v1.0.0

2. Version Preparation:
   Update version numbers
   Final testing
   Documentation updates

3. Complete Release:
   git checkout main
   git merge release/v1.0.0
   git tag -a v1.0.0 -m "Version 1.0.0"
   git push origin main --tags
   
   git checkout develop
   git merge release/v1.0.0
   git push origin develop

## Commit Standards
### Commit Message Format
type(scope): subject

Types:
- feat: New feature
- fix: Bug fix
- docs: Documentation
- style: Formatting
- refactor: Code restructuring
- test: Adding tests
- chore: Maintenance

### Examples
- feat(auth): implement permission handlers
- fix(capture): resolve screenshot timing issue
- docs(api): update endpoint documentation

## Pull Request Process
1. Create Pull Request
   - Clear title and description
   - Reference related issues
   - Include testing details
   - Add relevant labels

2. Review Requirements
   - Code review by team member
   - CI/CD checks passed
   - Documentation updated
   - Tests included

3. Merge Guidelines
   - Squash and merge preferred
   - Delete branch after merge
   - Update related issues

## Version Control
### Semantic Versioning
- Major.Minor.Patch
- Example: 1.0.0

### Version Tags
- Release candidates: v1.0.0-rc.1
- Beta versions: v1.0.0-beta.1
- Alpha versions: v1.0.0-alpha.1

## Best Practices
1. Regular Commits
   - Commit early and often
   - Keep commits focused
   - Use clear messages

2. Branch Management
   - Regular develop syncs
   - Clean up merged branches
   - Keep branches updated

3. Code Review
   - Detailed reviews
   - Constructive feedback
   - Quick response times

## Tools and Integration
1. Git Hooks
   - Pre-commit linting
   - Commit message validation
   - Automated testing

2. CI/CD Integration
   - Automated builds
   - Test execution
   - Deployment pipelines

3. Code Quality
   - SwiftLint integration
   - Test coverage checks
   - Documentation validation

## Emergency Procedures
1. Critical Bugs
   - Create hotfix branch
   - Expedited review process
   - Immediate deployment

2. Recovery Steps
   - Revert capabilities
   - Backup procedures
   - Rollback protocols

## Workflow Automation
1. GitHub Actions
   - Automated testing
   - Build verification
   - Documentation generation

2. Quality Gates
   - Code coverage thresholds
   - Performance benchmarks
   - Security scanning
