Maintaining up-to-date headers (e.g. Copyright headers) is really boring. This automates it.
auto-header/
├── src/
│ └── auto_header/
│ ├── __init__.py # Package initialization
│ ├── core.py # Core classes (FileSection, FileHandler base class)
│ ├── handlers/ # Directory for all file type handlers
│ │ ├── __init__.py # Handler registration
│ │ ├── powershell.py # PowerShell handler
│ │ ├── python.py # Python handler
│ │ ├── bash.py # Bash handler
│ │ ├── terraform.py # Terraform handler
│ │ └── yaml.py # YAML handler
│ ├── cli.py # Command-line interface
│ └── main.py # AutoHeader class and main functionality
├── tests/
│ ├── __init__.py
│ ├── test_core.py # Tests for core functionality
│ └── handlers/ # Handler-specific tests
│ ├── __init__.py
│ ├── test_powershell.py
│ ├── test_python.py
│ └── ...
│
├── .gitignore
├── pyproject.toml # Modern Python packaging config
├── README.md
└── .pre-commit-hooks.yaml # Pre-commit hook configuration
- Clone the repository:
git clone [email protected]:yourusername/auto-header.git
cd auto-header- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install development dependencies:
pip install -e ".[dev]"- Install pre-commit hooks:
pre-commit installpytestOr with coverage:
pytest --cov=auto_header tests/Invoking the version command without any arguments will display the current version of the project:
$ hatch version
0.0.1You can update the version like so:
$ hatch version "0.1.0"
Old: 0.0.1
New: 0.1.0The scheme option determines the scheme to use for parsing both the existing and new versions. The standard scheme is used by default, which is based on PEP 440.
Rather than setting the version explicitly, you can select the name of a segment used to increment the version:
$ hatch version minor
Old: 0.1.0
New: 0.2.0You can chain multiple segment updates with a comma. For example, if you wanted to release a preview of your project's first major version, you could do:
$ hatch version major,rc
Old: 0.2.0
New: 1.0.0rc0When you want to release the final version, you would do:
$ hatch version release
Old: 1.0.0rc0
New: 1.0.0auto-header --directory /path/to/your/filesauto-header --directory /path/to/your/files --header "Copyright YourCompany Ltd 2025"auto-header --directory /path/to/your/files --ignore "*.txt" "temp/*" ".git/*"Process all supported files in a directory, adding a custom header, ignoring specific files and patterns.
auto-header
--directory /path/to/your/files \
--header "Copyright Example Corp 2025" \
--ignore "tests/data.txt" "temp/*" ".git/*"Add to your project's .pre-commit-config.yaml:
repos:
- repo: https://github.com/yourusername/auto-header
rev: v0.1.0
hooks:
- id: auto-header
args: [--header, "Copyright Example Ltd, UK 2025"]