expand repoid to 16 chars and avoid querying git for it twice

i.e., just reuse GITVERSION, and FWIW, the current ID length git
auto chooses is 9 chars, suggesting that 8 really was getting to
small. With 16 we got now 64 bits, that's plenty for the next few
years.

Document the format also (roughly) in the API schema

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-05-29 14:44:24 +02:00
parent 147d67c495
commit 0e77456f1f
3 changed files with 6 additions and 6 deletions

View File

@ -9,10 +9,7 @@ DESTDIR=
SUBDIRS = aplinfo PVE bin www services configs network-hooks test
GITVERSION:=$(shell git rev-parse HEAD)
# possibly set via debian/rules(.env)
REPOID?=$(shell git rev-parse --short=8 HEAD)
GITVERSION:=$(shell git rev-parse --short=16 HEAD)
DEB=$(PACKAGE)_$(VERSION)_$(DEB_BUILD_ARCH).deb
@ -36,7 +33,7 @@ $(DEB):
mkdir dest
rsync -a * dest
echo "git clone git://git.proxmox.com/git/pve-manager.git\\ngit checkout $(GITVERSION)" > dest/debian/SOURCE
echo "REPOID_GENERATED=$(REPOID)" > dest/debian/rules.env
echo "REPOID_GENERATED=$(GITVERSION)" > dest/debian/rules.env
cd dest; dpkg-buildpackage -b -us -uc
lintian $(DEB)

View File

@ -104,6 +104,8 @@ __PACKAGE__->register_method ({
},
repoid => {
type => 'string',
# length 8 is old (< 8.0) short-id, 16 is new short id, 40 is sha1 and 64 is sha256
pattern => '[0-9a-fA-F]{8,64}',
description => 'The short git revision from which this version was build.',
},
console => {

View File

@ -19,8 +19,9 @@ PERLSOURCE = \
all: pvecfg.pm $(SUBDIRS)
set -e && for i in $(SUBDIRS); do $(MAKE) -C $$i; done
REPOID ?= $(or $(GITVERSION), $(shell git rev-parse --short=16 HEAD), unknown)
pvecfg.pm: pvecfg.pm.in
sed -e s/@VERSION@/$(VERSION)/ -e s/@PVERELEASE@/$(PVERELEASE)/ -e s/@PACKAGE@/$(PACKAGE)/ -e s/@REPOID@/$(REPOID)/ $< >$@.tmp
sed 's/@VERSION@/$(VERSION)/;s/@PVERELEASE@/$(PVERELEASE)/;s/@PACKAGE@/$(PACKAGE)/;s/@REPOID@/$(REPOID)/' $< >$@.tmp
mv $@.tmp $@
%: