Skip to content
Snippets Groups Projects
Commit bbbfdae5 authored by Igor Chorążewicz's avatar Igor Chorążewicz
Browse files

common: prepend release number to version when using GIT_VERSION

It allows tools which expect version in form major.minor to work
correctly even in case when pmdk is downloaded as zip archive.

This patch also removes '%d' from GIT_VERSION file. This placeholder
was filled with name of the branch only for the HEAD of a branch.
This means that GIT_VERSION of a selceted revision had different content
(either only commit hash or commit hash + name of the branch) depending
on whether selected revision was HEAD of the branch or not. Different
content of GIT_VERSION affected hash of the archive (and caused problems
with vcpkg in the past).
parent cc8c4f5c
No related branches found
No related tags found
No related merge requests found
$Format:%h %d$
\ No newline at end of file
$Format:%h$
\ No newline at end of file
#
# Copyright 2016, Intel Corporation
# Copyright 2016-2020, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -70,19 +70,14 @@ if (Test-Path $file_path) {
}
$git_version = ""
$git_version_tag = ""
$git_version_hash = ""
if (Test-Path $git_version_file) {
$git_version = Get-Content $git_version_file
if ($git_version -eq "`$Format:%h %d`$") {
if ($git_version -eq "`$Format:%h`$") {
$git_version = ""
} elseif ($git_version -match "tag: ") {
if ($git_version -match "tag: (?<tag>[0-9a-z.+-]*)") {
$git_version_tag = $matches["tag"];
}
} else {
$git_version_hash = ($git_version -split " ")[0]
$git_version_hash = $git_version
}
}
......@@ -97,12 +92,6 @@ if ($null -ne $args[0]) {
} elseif (Test-Path $version_file) {
$version = Get-Content $version_file
$ver_array = $version.split("-+")
} elseif ($null -ne $git) {
$version = $(git describe)
$ver_array = $(git describe --long).split("-+")
} elseif ($git_version_tag -ne "") {
$version = $git_version_tag
$ver_array = $git_version_tag.split("-+")
} elseif ($git_version_hash -ne "") {
$MAJOR = 0
$MINOR = 0
......@@ -112,6 +101,9 @@ if ($null -ne $args[0]) {
$version = $git_version_hash
$CUSTOM = $true
$version_custom_msg = "#define VERSION_CUSTOM_MSG `"$git_version_hash`""
} elseif ($null -ne $git) {
$version = $(git describe)
$ver_array = $(git describe --long).split("-+")
} else {
$MAJOR = 0
$MINOR = 0
......
#!/usr/bin/env bash
#
# Copyright 2017-2018, Intel Corporation
# Copyright 2017-2020, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -40,7 +40,7 @@ if [ -f "$1/VERSION" ]; then
fi
if [ -f $1/GIT_VERSION ]; then
echo -n "\$Format:%h %d\$" | cmp -s $1/GIT_VERSION - && true
echo -n "\$Format:%h\$" | cmp -s $1/GIT_VERSION - && true
if [ $? -eq 0 ]; then
PARSE_GIT_VERSION=0
else
......@@ -50,17 +50,13 @@ else
PARSE_GIT_VERSION=0
fi
if [ $PARSE_GIT_VERSION -eq 1 ]; then
GIT_VERSION_TAG=$(cat $1/GIT_VERSION | grep tag: | sed 's/.*tag: \([0-9a-z.+-]*\).*/\1/')
GIT_VERSION_HASH=$(cat $1/GIT_VERSION | sed -e 's/ .*//')
LATEST_RELEASE=$(cat $1/ChangeLog | grep "* Version" | cut -d " " -f 3 | sort -rd | head -n1)
if [ -n "$GIT_VERSION_TAG" ]; then
echo "$GIT_VERSION_TAG"
exit 0
fi
if [ $PARSE_GIT_VERSION -eq 1 ]; then
GIT_VERSION_HASH=$(cat $1/GIT_VERSION)
if [ -n "$GIT_VERSION_HASH" ]; then
echo "$GIT_VERSION_HASH"
echo "$LATEST_RELEASE+git.$GIT_VERSION_HASH"
exit 0
fi
fi
......@@ -78,7 +74,7 @@ fi
# try commit it, git describe can fail when there are no tags (e.g. with shallow clone, like on Travis)
GIT_COMMIT=$(git log -1 --format=%h) && true
if [ -n "$GIT_COMMIT" ]; then
echo "$GIT_COMMIT"
echo "$LATEST_RELEASE+git.$GIT_COMMIT"
exit 0
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment