Skip to content

Instantly share code, notes, and snippets.

@jmkim
Last active March 3, 2025 09:28
Show Gist options
  • Save jmkim/a840a1b7cf2b986f978941c7244d709e to your computer and use it in GitHub Desktop.
Save jmkim/a840a1b7cf2b986f978941c7244d709e to your computer and use it in GitHub Desktop.
Upstream dirty tags versioning in Debian

Upstream dirty tags versioning in Debian

Debian versioning

For never tagged upstream

Run on terminal

git --no-pager log -1 --date="format:%Y%m%d" --pretty="0.0~git%cd.%h"

Result

0.0~git20150607.4976a6c

For annotated upstream

Upstream versions

In case of the tag starts with numberic value

0.9.1
0.9
0.8

Run on terminal

git --no-pager log -1 --date="format:%Y%m%d" --pretty="$(git describe)+git%cd.%h"

Result

0.9.1+git20150607.4976a6c

For tagged upstream

Upstream versions

In case of the tag starts with v

v0.9.1
v0.9
v0.8

Run on terminal

git --no-pager log -1 --date="format:%Y%m%d" --pretty="$(git describe --tags --abbrev=0)+git%cd.%h" | sed 's/^v//'
# Note that ^v in sed can be replaced for your real cases

Result

0.9.1+git20150607.4976a6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment