A set of tools to manage a code repository using trunk based development and CalVer.
Project description
Overview
This repository contains several useful utilities:
- A BASH script which determines the version number of a git repository
- A python module which contains a function which calls the BASH script and then produces a PEP440 compliant version number.
- Scripts to install/uninstall the BASH script, and accompanying libraries, to
/usr/local/bin
- A setup.py allowing this project to be installed as a pip package
- An example Setup.py showing how the python function can be called to version a package automatically.
Versioning
The version number follows the CalVer versioning scheme. Each version consists of 5 parts:
- Major - Year of the commit
- Minor - Month of the commit
- Micro - Day of the commit
- Modifier - Branch and either commit hash or build number
The version number will thus be as follows:
<year>.<month>.<day>.<branch_type>.<commit_hash_or_build_number>
Note: For the PEP440 standard compliance, the python function will return a version number as follows (notice the '+'):
<year>.<month>.<day>+<branch_type>.<commit_hash_or_build_number>
The logic to construct the version number assumes the repository is following the Trunk Based Development branching strategy:
Branch Type Branch Flow
==================================================================
release/* ------------- --------
/ \ / /
patch/* / ----- /
/ \ /
master --------------------------------------------
(aka. main, integration) \ \ /\ /
\ \ / \ /
feature/* \ -------------- \ /
\ \ /
bug/* ------------------------
Each commit in the branch flow will be given a version number based on the CalVer versioning strategy.
Integration branches like master and release will use a build number for the suffix. Non-integration branches which can occur in parallel will use the first 7 digits of the commit hash as the suffix.
Examples include:
- 2023.05.23.master.1
- 2022.12.01.feature.f3b24e1
Requirements
- BASH >= 4.2
- git >= 1.8
Installation
The scripts can be installed by themselves (i.e. without a python dependency) by running the install.sh found in the scrips/
directory. This script will copy the scripts to the /usr/local/bin
and the libraries to /usr/local/<directory-name>
paths.
The python package (and the scripts) can be installed by installing the pip package. The setup.py is configured to copy the bash scripts to the same place as the install.sh
. It will also install a python module which hosts a function. Once installed, the module can be imported and the function can be run. The function in turn calls the installed bash scripts.
Usage
Once installed, simply navigate the current working directory to be inside a git repository and run the bash script or call the python function to determine the version number for that repository.
TODO
In a future release a flag will be added to allow inspecting repositories by specifying a path rather than manipulating the CWD.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tbd-calver-versioning-2023.5.26rc3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41843bc190f545a1db701344f3c3d7013db94da8207d4f6abe2f1e6e50065824 |
|
MD5 | b3ef12661ccd8d78fef68a8d69e95382 |
|
BLAKE2b-256 | f5e7794c9cc30bf6c755b5b1d14a086e1f7c26a7a0504297325403a2e5a0c8ef |
Hashes for tbd_calver_versioning-2023.5.26rc3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daa71cdae956d53daf51cd355aaa9d44c8b2a17b079eeffe332a1ab07a6cea94 |
|
MD5 | 2264b07bed357154ee093455b51819b6 |
|
BLAKE2b-256 | 94d5b8fad7fc31f519c6abffd82cacb6ed303dca44d0809b917e230b77931aba |