Skip to content

git.py: Make `ref` human readable

Jürg Billeter requested to merge juerg/git-describe into master

Tracking git branches currently only returns the SHA-1 object name of the commit, which is not human-readable. This can make it very cumbersome to determine the exact package version.

This patch prepends a version string to the ref when tracking sources that have tags, using git describe.

Examples:

- kind: git
  url: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
  track: linux-4.15.y
  ref: v4.15.7-0-gcb4a115a42867def71fdcbf0d7b714f268ff37fd
- kind: git
  url: https://gitlab.gnome.org/GNOME/glib.git
  track: glib-2-54
  ref: 2.54.3-18-gfba630a5605910774f29b74c48cf1660125b7f4c

Original proposal (replaced by the above)

This patch additionally returns a version key with the output of git describe, if available.

Example result of tracking a meson stable branch where HEAD is tagged:

sources:
- kind: git
  url: https://github.com/mesonbuild/meson
  track: '0.44'
  version: 0.44.1
  ref: e2b6902468c8077bfd50f0f7f26f0dc6db90f44f

Example result of tracking glib master where HEAD is not tagged:

sources:
- kind: git
  url: https://gitlab.gnome.org/GNOME/glib.git
  track: master
  version: 2.55.1-165-g6cea0c68f
  ref: 6cea0c68fb4059242c4cc164b46813bb8b4fc313
Edited by Jürg Billeter

Merge request reports