Skip to content

Commit

Permalink
Fix --version for new branch structure (#2407)
Browse files Browse the repository at this point in the history
* Fix version flag

* Fix test

* Get full information
  • Loading branch information
Baltoli authored Jan 24, 2022
1 parent 95f32fa commit d3f5f62
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion k-distribution/tests/regression-new/help/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TESTDIR=.
KRUN_FLAGS=--help
KOMPILE_FLAGS=--syntax-module TEST
PACKAGE_VERSION ?= $(shell cat ../../../../package/version)
GIT_REVISION=$(shell git describe --tags --long)
GIT_REVISION=$(shell ../../../../scripts/get-version-string.sh)
VERSION_REGEX="$(PACKAGE_VERSION)\|$(GIT_REVISION)"
KPARSE=${K_BIN}/kparse
KPARSE_GEN=${K_BIN}/kparse-gen
Expand Down
6 changes: 1 addition & 5 deletions kernel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,10 @@
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<exec executable="git"
<exec executable="../scripts/get-version-string.sh"
outputproperty="git.describe.out"
errorproperty="git.describe.err"
failifexecutionfails="false">
<arg value="describe" />
<arg value="--tags" />
<arg value="--dirty" />
<arg value="--long" />
</exec>
</target>
</configuration>
Expand Down
19 changes: 19 additions & 0 deletions scripts/get-version-string.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

MERGE_BASE=$(git merge-base master HEAD)
VERSION_TAG=$(git describe --contains --always "$MERGE_BASE" | sed 's/~.*//')

VERSION_STRING=$VERSION_TAG

DISTANCE=$(git rev-list --count "$MERGE_BASE"..HEAD)
VERSION_STRING+="-$DISTANCE"

SHA=$(git rev-parse --short HEAD)
VERSION_STRING+="-g$SHA"

DIRTY=$(git diff HEAD)
if [ -n "$DIRTY" ]; then
VERSION_STRING+=-dirty
fi

echo $VERSION_STRING

0 comments on commit d3f5f62

Please sign in to comment.