Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2835395
feat: Add comprehensive Polish legislative process documentation and PRD
bmcszk Jun 27, 2025
f503bf1
feat: Implement Phase 1 Sprint 1 - Enhanced Act Lifecycle Tracking Da…
bmcszk Jun 27, 2025
4f32452
feat: Implement Phase 1 Sprint 1 - Enhanced Act Lifecycle Tracking Da…
bmcszk Jun 27, 2025
9660a23
feat: Implement Phase 2 Sprint 3 - Enhanced Board UI with 6-Column Li…
bmcszk Jun 27, 2025
f843c4c
feat: Complete Phase 2 Sprint 3 - Enhanced Act Lifecycle Tracking UI
bmcszk Jun 27, 2025
65b17a2
feat: Implement Phase 3 Sprint 4 - Background Enrichment Service
bmcszk Jun 27, 2025
94124e7
feat: Implement Act Status Change Monitoring and Notifications
bmcszk Jun 27, 2025
8545be8
feat: Implement comprehensive data validation system for Phase 3 Spri…
bmcszk Jun 27, 2025
cf92bdf
fix: Add missing test mocks for background service operations
bmcszk Jun 27, 2025
3266a74
feat: Implement comprehensive search and filtering system
bmcszk Jun 27, 2025
22d09da
fix: Address linting issues and improve test mocks
bmcszk Jun 27, 2025
7a70ffb
feat: Implement act comparison and diff visualization system
bmcszk Jun 27, 2025
00b2201
fix: Resolve compilation errors and cognitive complexity issues
bmcszk Jun 27, 2025
6485752
feat: Add comprehensive pre-commit hooks for code quality
bmcszk Jun 27, 2025
dfbb888
feat: Complete Phase 4 Sprint 5 - Export functionality (PDF, CSV, JSON)
bmcszk Jun 27, 2025
ca3ba2b
fix: Continue linting fixes - reduce issues from 139 to 106
bmcszk Jun 28, 2025
2a84392
fix: Resolve test deadlocks and complete comprehensive linting cleanup
bmcszk Jun 28, 2025
75518ba
fix: Resolve Critical Server Startup Issues and Template Errors
bmcszk Jun 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Git Hooks for Ustawka

This directory contains git hooks to maintain code quality and enforce development workflows.

## Available Hooks

### pre-commit
- **Purpose**: Ensures code quality before commits
- **Features**:
- Prevents direct commits to protected branches (`master`, `main`, `RELEASE`)
- Runs `make check` to verify linting and tests pass
- Provides helpful error messages and suggestions

## Installation

### Automatic Setup (Recommended)
```bash
# From project root
./scripts/setup-hooks.sh
```

### Manual Setup
```bash
# Copy the hook to your local git hooks directory
cp .githooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
```

## Usage

Once installed, the hooks run automatically:

```bash
# This will trigger the pre-commit hook
git commit -m "your commit message"
```

### Protected Branches
The pre-commit hook prevents direct commits to:
- `master`
- `main`
- `RELEASE`

If you try to commit to these branches, you'll see:
```
❌ ERROR: Direct commits to 'master' branch are not allowed!
πŸ’‘ Please use a feature branch and create a pull request instead.
```

### Code Quality Checks
The hook runs `make check` which includes:
- Go linting (`golangci-lint`)
- Unit tests
- Code formatting verification

If checks fail, you'll see detailed error messages and suggestions for fixes.

## Recommended Workflow

1. **Create a feature branch**:
```bash
git checkout -b feat/your-feature-name
```

2. **Make your changes and commit**:
```bash
git add .
git commit -m "feat: add your feature description"
```

3. **Push and create PR**:
```bash
git push -u origin feat/your-feature-name
# Create pull request via GitHub/GitLab
```

## Bypassing Hooks (Emergency Only)

In rare cases where you need to bypass the hook:
```bash
git commit --no-verify -m "emergency commit"
```

**⚠️ Warning**: Only use `--no-verify` in true emergencies. The hooks exist to maintain code quality.

## Troubleshooting

### Hook not running
- Ensure the hook file is executable: `chmod +x .git/hooks/pre-commit`
- Check that you're in the project root directory
- Verify the hook file exists in `.git/hooks/pre-commit`

### Make check failures
- Run `make check` manually to see detailed errors
- Common fixes:
- `go fmt ./...` for formatting issues
- `goimports -w .` for import organization
- Fix test failures shown in output

### Missing dependencies
- Ensure you have all required tools:
- `golangci-lint` for linting
- `gotestsum` for test execution (optional)
- Go toolchain properly installed

## Contributing

When adding new hooks:
1. Add the hook file to `.githooks/`
2. Update this README
3. Update `scripts/setup-hooks.sh` if needed
4. Test the hook thoroughly before committing
87 changes: 87 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

# Pre-commit hook for Ustawka project
#
# This hook ensures code quality by:
# 1. Preventing direct commits to protected branches (master, main, RELEASE)
# 2. Running make check to verify linting and tests pass
#
# To install this hook for your local development:
# cp .githooks/pre-commit .git/hooks/pre-commit
# chmod +x .git/hooks/pre-commit

set -e

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Get current branch name
current_branch=$(git branch --show-current)

echo -e "${BLUE}πŸ” Ustawka Pre-commit Hook${NC}"
echo -e "${YELLOW}Checking branch and code quality...${NC}"

# 1. Check if we're trying to commit to protected branches
protected_branches=("master" "main" "RELEASE")

for protected in "${protected_branches[@]}"; do
if [[ "$current_branch" == "$protected" ]]; then
echo -e "${RED}❌ ERROR: Direct commits to '$protected' branch are not allowed!${NC}"
echo -e "${YELLOW}πŸ’‘ Please use a feature branch and create a pull request instead.${NC}"
echo -e ""
echo -e "${YELLOW} Create a feature branch:${NC}"
echo -e " git checkout -b feature/your-feature-name"
echo -e " git add ."
echo -e " git commit -m 'your commit message'"
echo -e " git push -u origin feature/your-feature-name"
echo -e ""
echo -e "${YELLOW} Or use our git flow:${NC}"
echo -e " git checkout -b feat/short-description"
echo -e " # Make your changes, then:"
echo -e " git add . && git commit -m 'feat: your feature description'"
echo -e " git push -u origin feat/short-description"
exit 1
fi
done

echo -e "${GREEN}βœ“ Branch check passed: '$current_branch'${NC}"

# 2. Ensure we're in the project root (where Makefile exists)
if [[ ! -f "Makefile" ]]; then
echo -e "${RED}❌ ERROR: Makefile not found! Please run this from the project root.${NC}"
exit 1
fi

# 3. Run make check to ensure code quality
echo -e "${YELLOW}πŸ” Running make check (linting + unit tests)...${NC}"
echo -e "${BLUE}This may take a moment...${NC}"

if ! make check; then
echo -e ""
echo -e "${RED}❌ ERROR: make check failed!${NC}"
echo -e "${YELLOW}πŸ’‘ Please fix the following before committing:${NC}"
echo -e " β€’ Linting issues (run 'make lint' for details)"
echo -e " β€’ Test failures (run 'make test-unit' for details)"
echo -e ""
echo -e "${YELLOW} Quick fixes:${NC}"
echo -e " β€’ For formatting: Run 'go fmt ./...'"
echo -e " β€’ For imports: Run 'goimports -w .'"
echo -e " β€’ For linting: Check 'golangci-lint run'"
echo -e ""
echo -e "${BLUE} Tip: You can run 'make check' manually to see all issues.${NC}"
exit 1
fi

echo -e ""
echo -e "${GREEN}βœ“ make check passed!${NC}"
echo -e "${GREEN}πŸŽ‰ All pre-commit checks passed. Proceeding with commit...${NC}"

# Optional: Show commit stats
staged_files=$(git diff --cached --name-only | wc -l)
echo -e "${BLUE}πŸ“ Committing ${staged_files} file(s) on branch '${current_branch}'${NC}"

exit 0
6 changes: 5 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ Key environment variables:
- Always run `make check` before commits (linting + unit tests required)
- Service layer implements timeout management for external API calls
- Metrics tracking available at `/metrics` endpoint
- Database schema automatically handles migrations via triggers
- Database schema automatically handles migrations via triggers

## Git Practices

- NEVER commit with "--no-verify"
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.PHONY: check build run test test-unit test-e2e lint clean install-lint install-gotestsum
.PHONY: check vet build run test test-unit test-e2e lint clean install-lint install-gotestsum

# Binary name
BINARY_NAME=ustawka
GOTEST=gotestsum --junitfile unit-tests.xml --
GOLANGCI_LINT_CMD := golangci-lint

# Check: lint, and unit tests (no Docker)
check: lint test-unit
check: vet lint test-unit
@echo "Linters, and unit tests completed."

vet:
@echo "Vet..."
@go vet ./...

# Build the application
build:
@echo "Building..."
Expand Down
Loading