Versioning and Cataloguing Engineering Code: Header Blocks, Semantic Versions and Git
Engineers accumulate scripts and small tools quickly: data converters, calculators, rig controllers, report generators. Without discipline, copies multiply on laptops and pen drives, and nobody knows which is current. A small set of habits fixes this: a header block in every file, semantic version numbers, git history, a predictable folder layout, and a catalogue generated from the headers.
Key takeaways
- Put a header block at the top of every file: tool name, family, version, date, origin and a changes line.
- Semantic versioning MAJOR.MINOR.PATCH: breaking change → MAJOR, new feature → MINOR, fix → PATCH.
- Git gives history and safe experiments: commit small logical changes with clear messages; tag releases.
- Group tools into family repositories under one portable root and use relative links so the root can move between drives.
- Generate a catalogue (index page) by scanning headers, and keep three copies on two media types, one off-site (3-2-1).
1. Header blocks
<!DOCTYPE html> <!-- TOOL: Spring Rate Calculator FAMILY: spring-tools VERSION: 2.3.1 DATE: 2026-11-24 CHAT: origin / discussion reference CHANGES: 2.3.1 Fixed unit conversion for N/mm to lbf/in STATUS: Released -->
In Python, use a module docstring or comment block with the same fields and keep __version__ in step with VERSION. A catalogue script can then read every file's header without running it.
2. Semantic versioning
| Change | Bump | Example |
|---|---|---|
| Breaking change: inputs, outputs or file format no longer compatible | MAJOR | 1.4.2 → 2.0.0 |
| New feature, backward compatible | MINOR | 1.4.2 → 1.5.0 |
| Bug fix, no new feature | PATCH | 1.4.2 → 1.4.3 |
| Pre-release | suffix | 2.0.0-rc.1 |
3. A minimal git routine
git init # once per repository git add spring_calc.html git commit -m "spring-tools 2.3.1: fix N/mm to lbf/in conversion" git tag v2.3.1 # mark a release git log --oneline --graph # history git switch -c try-new-layout # experiment safely on a branch git switch main && git merge try-new-layout git push origin main --tags # if a remote (e.g. GitHub, private) is used
| Good practice | Why |
|---|---|
| One logical change per commit | Easy to review and undo |
| Message: what and why, with version | History reads like a change log |
| .gitignore for outputs, data, secrets | Keeps repos small and safe |
| Tags for releases | Exact version can be rebuilt |
| Private remote or second disk | Backup and access from other machines |
4. Layout and catalogue
- Use relative links (
spring-tools/spring_calc.html), never drive letters, so the root works from any drive or path. - The catalogue script reads TOOL, FAMILY, VERSION, DATE and CHANGES, warns about files without headers or with duplicate names, and writes the index.
- Backups: 3 copies, 2 media types, 1 off-site (for example: working drive, external drive, private cloud repository).
5. Calculators
Version bump and header block generator
6. Self-test: check your understanding
Pick an answer to see the explanation. Numerical answers are accepted within the stated tolerance (±3 % unless noted).
Score
7. References and further reading
- Preston-Werner, T., Semantic Versioning 2.0.0, semver.org.
- Chacon, S. and Straub, B., Pro Git, 2nd ed., Apress, 2014 (free online).
- Wilson, G. et al., 'Good enough practices in scientific computing', PLOS Computational Biology, 13(6), 2017.