From: Ben Crocker <bcrocker(a)redhat.com>
⢠Makefile.common: make HEAD an overridable variable.
Change
GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
to
GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
making the argument to 'git log' explicit and allowing it to be
overridden by, e.g., self-tests.
⢠1005-dist-dump-variables.bats: override HEAD with the tag under test;
simplifies (and speeds up) prologue, obviates epilogue, makes the
whole process more robust by eliminating even temporary changes to
the git repo;
⢠egit.sh: eliminate as-yet-unused merge-base case.
Signed-off-by: Ben Crocker <bcrocker(a)redhat.com>
[redhat] Makefile.common: fix GITID for overridable HEAD
Signed-off-by: Ben Crocker <bcrocker(a)redhat.com>
---
redhat/Makefile.common | 13 ++++++-----
.../self-test/1005-dist-dump-variables.bats | 23 +------------------
redhat/self-test/egit.sh | 9 --------
3 files changed, 8 insertions(+), 37 deletions(-)
diff --git a/redhat/Makefile.common b/redhat/Makefile.common
index 80c3b8dfccd4..cdffa9fb3d3d 100644
--- a/redhat/Makefile.common
+++ b/redhat/Makefile.common
@@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo
rpmbuild; \
else echo rpm; fi)
MACH := $(shell uname -m)
-RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\
/{s///;p;q}')
-RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\
/{s///;p;q}')
-RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\
/{s///;p;q}')
-RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\
/{s///;p;q}')
-GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
+HEAD ?= HEAD
+RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\
/{s///;p;q}')
+RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\
/{s///;p;q}')
+RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\
/{s///;p;q}')
+RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\
/{s///;p;q}')
+GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
# marker is git tag which we base off of for exporting patches
# Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel
# makefile as opposed to any adjusted version for snapshotting.
@@ -42,7 +43,7 @@ else
endif
ifeq ($(VERSION_ON_UPSTREAM),1)
# master is expected to track mainline.
- MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
+ MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master)
_TAG:=$(shell $(GIT) describe $(MERGE_BASE))
# a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash]
SNAPSHOT:=$(shell echo $(_TAG) | grep -c '\-g')
diff --git a/redhat/self-test/1005-dist-dump-variables.bats
b/redhat/self-test/1005-dist-dump-variables.bats
index 2ebea70baf59..bff950e6643a 100644
--- a/redhat/self-test/1005-dist-dump-variables.bats
+++ b/redhat/self-test/1005-dist-dump-variables.bats
@@ -1,27 +1,10 @@
#!/usr/bin/env bats
-function get_rpmversion
-{
- # ts = tag or sha1
- ts=$1
- RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\
/{s///;p;q}')
- RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\
/{s///;p;q}')
- RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\
/{s///;p;q}')
- RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\
/{s///;p;q}')
-}
function prologue()
{
tag=$1
- git show $tag:Makefile > Makefile
- git add Makefile
- git commit -m "Temporarily replace with $tag Makefile"
ofile=$BATS_TMPDIR/$tag.out
- GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make
dist-dump-variables > $ofile
-}
-
-function epilogue()
-{
- git reset --hard HEAD^
+ GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make
dist-dump-variables > $ofile
}
@test "dist-dump-variables v5.8" {
@@ -32,7 +15,6 @@ function epilogue()
then
status=$?
fi
- epilogue
[ "$status" = 0 ]
}
@@ -44,7 +26,6 @@ function epilogue()
then
status=$?
fi
- epilogue
[ "$status" = 0 ]
}
@@ -56,7 +37,6 @@ function epilogue()
then
status=$?
fi
- epilogue
[ "$status" = 0 ]
}
@@ -68,6 +48,5 @@ function epilogue()
then
status=$?
fi
- epilogue
[ "$status" = 0 ]
}
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh
index b998f868a314..f26921cc2aca 100755
--- a/redhat/self-test/egit.sh
+++ b/redhat/self-test/egit.sh
@@ -12,15 +12,6 @@ case $arg in
git describe "$@"
fi
;;
- merge-base )
- if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
- then
- # This should be an SHA1:
- echo "$EGIT_OVERRIDE_MERGE_BASE"
- else
- git merge-base "$@"
- fi
- ;;
* )
git "$arg" "$@"
;;
--
GitLab