packit: use the closest matching tag for the checked out revision
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 23 Jan 2024 14:29:08 +0000 (15:29 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Jan 2024 17:15:13 +0000 (18:15 +0100)
Packit otherwise tries to get the latest tag by creation date, which
doesn't work well in the systemd-stable repo:

2024-01-23 13:40:47.858 upstream.py       DEBUG  No ref given or is not glob pattern
2024-01-23 13:40:47.859 upstream.py       DEBUG  We're about to get latest matching tag in the upstream repository /tmp/tmp07g2beo8.
2024-01-23 13:40:47.859 commands.py       DEBUG  Command: git tag --list --sort=-creatordate
2024-01-23 13:40:47.866 logging.py        DEBUG  v248.13
2024-01-23 13:40:47.866 logging.py        DEBUG  v249.17
2024-01-23 13:40:47.866 logging.py        DEBUG  v250.14
2024-01-23 13:40:47.866 logging.py        DEBUG  v251.20
2024-01-23 13:40:47.867 logging.py        DEBUG  v252.21
2024-01-23 13:40:47.867 logging.py        DEBUG  v253.15
2024-01-23 13:40:47.867 logging.py        DEBUG  v254.8
2024-01-23 13:40:47.867 logging.py        DEBUG  v255.2
2024-01-23 13:40:47.868 logging.py        DEBUG  v255.1
2024-01-23 13:40:47.868 logging.py        DEBUG  v255
...

.packit.yml

index db133f4dc56f6bbc9d4ec8c893c30adc9e155b8a..1775221bd1c7063a9b588e72ecb078be349a769b 100644 (file)
@@ -16,6 +16,13 @@ upstream_tag_template: "v{version}"
 srpm_build_deps: []
 
 actions:
+  get-current-version:
+    # Show the closest matching tag for the checked out revision, otherwise
+    # Packit tries to get the latest tag by creation date, which doesn't work
+    # well in the systemd-stable repo. We also need to sanitize it manually
+    # since "upstream_tag_template" defined above doesn't apply here.
+    - "bash -ec 'git describe --tags --abbrev=0 | cut -b 2-'"
+
   post-upstream-clone:
     # Use the Fedora Rawhide specfile
     - "git clone https://src.fedoraproject.org/rpms/systemd .packit_rpm --depth=1"