Este documento define as diretrizes para commits, builds e workflows Git no projeto PetCare AI Tasks. Seguindo essas práticas, mantemos um histórico limpo, builds consistentes e colaboração eficiente.
- main - Código de produção estável
- develop - Código de desenvolvimento integrado
- feature/ - Novas funcionalidades
- hotfix/ - Correções urgentes
- release/ - Preparação para release
- Um commit = Uma mudança lógica
- Commits pequenos e focados
- Fáceis de revisar e reverter
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
| Tipo | Emoji | Descrição | Exemplo |
|---|---|---|---|
feat |
✨ | Nova funcionalidade | feat(auth): add biometric login |
fix |
🐛 | Correção de bug | fix(tasks): resolve sync issue |
docs |
📚 | Documentação | docs(readme): update installation guide |
style |
💄 | Formatação, estilo | style(components): fix eslint warnings |
refactor |
♻️ | Refatoração de código | refactor(services): extract api calls |
perf |
⚡ | Melhoria de performance | perf(list): optimize rendering |
test |
🧪 | Testes | test(auth): add login flow tests |
build |
📦 | Sistema de build | build(expo): update to v50 |
ci |
👷 | CI/CD | ci(github): add automated tests |
chore |
🔧 | Manutenção | chore(deps): update dependencies |
revert |
⏪ | Reverter commit | revert: remove experimental feature |
- auth - Autenticação e autorização
- tasks - Funcionalidades de tarefas
- ui - Interface do usuário
- api - Integrações de API
- db - Banco de dados
- docs - Documentação
- config - Configurações
- deps - Dependências
# Funcionalidade nova
git commit -m "feat(tasks): add task filtering by category"
# Correção de bug
git commit -m "fix(auth): resolve token expiration handling"
# Documentação
git commit -m "docs(api): add endpoint documentation"
# Refatoração
git commit -m "refactor(components): extract reusable TaskCard"
# Performance
git commit -m "perf(list): implement virtual scrolling"
# Com corpo detalhado
git commit -m "feat(notifications): add push notification support
- Integrate with Firebase Cloud Messaging
- Add notification settings screen
- Handle notification permissions
- Support deep linking from notifications
Closes #123"# Muito vago
git commit -m "fix stuff"
# Múltiplas mudanças
git commit -m "add login, fix bugs, update docs"
# Sem contexto
git commit -m "wip"
# Informal
git commit -m "fixed the thing that was broken"graph LR
A[main] --> B[develop]
B --> C[feature/new-login]
C --> B
B --> D[release/v2.0.0]
D --> A
A --> E[hotfix/critical-bug]
E --> A
E --> B
# 1. Criar feature branch
git checkout develop
git pull origin develop
git checkout -b feature/task-categories
# 2. Trabalhar na feature
git add .
git commit -m "feat(tasks): add category selection"
# 3. Finalizar feature
git checkout develop
git pull origin develop
git merge feature/task-categories
git push origin develop
git branch -d feature/task-categories
# 4. Criar release
git checkout develop
git checkout -b release/v1.1.0
# Fazer ajustes finais, bump version, etc.
git checkout main
git merge release/v1.1.0
git tag v1.1.0
git push origin main --tags
# 5. Hotfix urgente
git checkout main
git checkout -b hotfix/security-patch
git commit -m "fix(auth): patch security vulnerability"
git checkout main
git merge hotfix/security-patch
git checkout develop
git merge hotfix/security-patch
git tag v1.1.1
git push origin main develop --tags# Features
feature/user-authentication
feature/task-categories
feature/dark-mode
# Hotfixes
hotfix/login-crash
hotfix/data-sync-issue
# Releases
release/v1.0.0
release/v2.0.0-beta
# Experiências
experiment/ai-suggestions
experiment/voice-commands| Tipo | Branch | Ambiente | Automático |
|---|---|---|---|
| Development | feature/* | Dev | ❌ |
| Staging | develop | Staging | ✅ |
| Release Candidate | release/* | RC | ✅ |
| Production | main | Prod | ✅ |
# 1. Verificar ambiente
npm run doctor
# 2. Executar testes
npm run test
npm run lint
npm run typecheck
# 3. Build local
npm run build:dev # Development
npm run build:staging # Staging
npm run build:prod # Production
# 4. Build para stores
npm run build:ios # iOS App Store
npm run build:android # Google Play{
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"build:dev": "expo build --clear-cache",
"build:staging": "expo build --release-channel staging",
"build:prod": "expo build --release-channel production",
"build:ios": "eas build --platform ios",
"build:android": "eas build --platform android",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"typecheck": "tsc --noEmit",
"doctor": "expo doctor"
}
}# .github/workflows/ci.yml
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test
- name: Type check
run: npm run typecheck
build:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install dependencies
run: npm ci
- name: Build for production
run: npm run build:prod# Pre-commit hooks
#!/bin/bash
# .git/hooks/pre-commit
echo "🔍 Running pre-commit checks..."
# Lint staged files
npm run lint-staged
# Run tests
npm run test --silent
# Type check
npm run typecheck
if [ $? -ne 0 ]; then
echo "❌ Pre-commit checks failed!"
exit 1
fi
echo "✅ Pre-commit checks passed!"## 📋 Descrição
Breve descrição das mudanças realizadas.
## 🎯 Tipo de Mudança
- [ ] 🐛 Bug fix (non-breaking change que corrige um problema)
- [ ] ✨ Nova feature (non-breaking change que adiciona funcionalidade)
- [ ] 💥 Breaking change (fix ou feature que quebra funcionalidade existente)
- [ ] 📚 Documentação
- [ ] 🔧 Chore (mudanças que não afetam o código)
## 🧪 Como Foi Testado?
Descreva os testes realizados para verificar as mudanças.
- [ ] Testes unitários
- [ ] Testes de integração
- [ ] Teste manual no iOS
- [ ] Teste manual no Android
- [ ] Teste manual na web
## 📱 Screenshots/GIFs
Se aplicável, adicione screenshots ou GIFs das mudanças na UI.
## ✅ Checklist
- [ ] Meu código segue as diretrizes do projeto
- [ ] Realizei uma auto-revisão do meu código
- [ ] Comentei partes complexas do código
- [ ] Minhas mudanças não geram novos warnings
- [ ] Adicionei testes que provam que minha correção é efetiva
- [ ] Testes novos e existentes passam localmente
- [ ] Atualizei a documentação quando necessário
## 🔗 Issues Relacionadas
Closes #123
Related to #456-
✅ Automated Checks Pass
- Todos os testes passam
- Linting sem erros
- Build bem-sucedido
-
👥 Code Review
- Pelo menos 1 aprovação
- Todas as conversas resolvidas
- Código segue padrões estabelecidos
-
📱 Testing
- Testado em iOS/Android
- Funcionalidade verificada
- Sem regressões
-
📚 Documentation
- Documentação atualizada
- README atualizado se necessário
- Changelog atualizado
MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]
Exemplo: 2.1.3-beta.1+20241120
- MAJOR (2.0.0) - Breaking changes
- MINOR (1.1.0) - Novas features compatíveis
- PATCH (1.0.1) - Bug fixes compatíveis
# Release final
git tag v1.2.0
git push origin v1.2.0
# Pre-release
git tag v1.2.0-beta.1
git push origin v1.2.0-beta.1
# Release candidate
git tag v1.2.0-rc.1
git push origin v1.2.0-rc.1{
"devDependencies": {
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"husky": "^8.0.0",
"lint-staged": "^13.0.0",
"standard-version": "^9.5.0"
}
}// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'build',
'ci',
'chore',
'revert'
]
],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [2, 'always', 'lower-case'],
'subject-max-length': [2, 'always', 50],
'body-max-line-length': [2, 'always', 72]
}
};{
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-push": "npm run test"
}
}
}{
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write",
"git add"
],
"*.{md,json}": [
"prettier --write",
"git add"
]
}
}# Instalar
npm install --save-dev standard-version
# Configurar script
"scripts": {
"release": "standard-version",
"release:minor": "standard-version --release-as minor",
"release:major": "standard-version --release-as major",
"release:dry": "standard-version --dry-run"
}
# Usar
npm run release # Patch release
npm run release:minor # Minor release
npm run release:major # Major release{
"standard-version": {
"releaseCommitMessageFormat": "chore(release): {{currentTag}}",
"types": [
{"type": "feat", "section": "✨ Features"},
{"type": "fix", "section": "🐛 Bug Fixes"},
{"type": "chore", "hidden": true},
{"type": "docs", "section": "📚 Documentation"},
{"type": "style", "hidden": true},
{"type": "refactor", "section": "♻️ Refactor"},
{"type": "perf", "section": "⚡ Performance"},
{"type": "test", "hidden": true}
]
}
}Commit rejeitado por hooks:
# Bypass hooks (usar com cuidado)
git commit --no-verify -m "emergency fix"
# Corrigir e tentar novamente
npm run lint:fix
git add .
git commit -m "fix(lint): resolve linting issues"Conflitos de merge:
# Resolver conflitos
git status
# Editar arquivos conflitantes
git add .
git commit -m "resolve merge conflicts"Build falhando:
# Limpar caches
npm run clean
rm -rf node_modules package-lock.json
npm install
# Verificar environment
npm run doctor- 📚 Documentação: docs/
- 💬 Slack: #dev-petcare-tasks
- 🐛 Issues: GitHub Issues
- 📧 Email: dev-team@petcare.com
📝 Última atualização: Janeiro 2025
👥 Mantido por: Equipe de Desenvolvimento PetCare
💡 Dica: Use o comando
git log --oneline --graphpara visualizar o histórico de commits de forma gráfica.