Skip to content
Snippets Groups Projects
Unverified Commit ae65484d authored by Marcin Ślusarz's avatar Marcin Ślusarz Committed by GitHub
Browse files

Merge pull request #4569 from igchor/fix_git_version

common: prepend release number to version when using GIT_VERSION
parents fc5e989a bbbfdae5
No related branches found
No related tags found
No related merge requests found
$Format:%h %d$ $Format:%h$
\ No newline at end of file \ 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 # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -70,19 +70,14 @@ if (Test-Path $file_path) { ...@@ -70,19 +70,14 @@ if (Test-Path $file_path) {
} }
$git_version = "" $git_version = ""
$git_version_tag = ""
$git_version_hash = "" $git_version_hash = ""
if (Test-Path $git_version_file) { if (Test-Path $git_version_file) {
$git_version = Get-Content $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 = "" $git_version = ""
} elseif ($git_version -match "tag: ") {
if ($git_version -match "tag: (?<tag>[0-9a-z.+-]*)") {
$git_version_tag = $matches["tag"];
}
} else { } else {
$git_version_hash = ($git_version -split " ")[0] $git_version_hash = $git_version
} }
} }
...@@ -97,12 +92,6 @@ if ($null -ne $args[0]) { ...@@ -97,12 +92,6 @@ if ($null -ne $args[0]) {
} elseif (Test-Path $version_file) { } elseif (Test-Path $version_file) {
$version = Get-Content $version_file $version = Get-Content $version_file
$ver_array = $version.split("-+") $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 "") { } elseif ($git_version_hash -ne "") {
$MAJOR = 0 $MAJOR = 0
$MINOR = 0 $MINOR = 0
...@@ -112,6 +101,9 @@ if ($null -ne $args[0]) { ...@@ -112,6 +101,9 @@ if ($null -ne $args[0]) {
$version = $git_version_hash $version = $git_version_hash
$CUSTOM = $true $CUSTOM = $true
$version_custom_msg = "#define VERSION_CUSTOM_MSG `"$git_version_hash`"" $version_custom_msg = "#define VERSION_CUSTOM_MSG `"$git_version_hash`""
} elseif ($null -ne $git) {
$version = $(git describe)
$ver_array = $(git describe --long).split("-+")
} else { } else {
$MAJOR = 0 $MAJOR = 0
$MINOR = 0 $MINOR = 0
......
#!/usr/bin/env bash #!/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 # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -40,7 +40,7 @@ if [ -f "$1/VERSION" ]; then ...@@ -40,7 +40,7 @@ if [ -f "$1/VERSION" ]; then
fi fi
if [ -f $1/GIT_VERSION ]; then 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 if [ $? -eq 0 ]; then
PARSE_GIT_VERSION=0 PARSE_GIT_VERSION=0
else else
...@@ -50,17 +50,13 @@ else ...@@ -50,17 +50,13 @@ else
PARSE_GIT_VERSION=0 PARSE_GIT_VERSION=0
fi fi
if [ $PARSE_GIT_VERSION -eq 1 ]; then LATEST_RELEASE=$(cat $1/ChangeLog | grep "* Version" | cut -d " " -f 3 | sort -rd | head -n1)
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/ .*//')
if [ -n "$GIT_VERSION_TAG" ]; then if [ $PARSE_GIT_VERSION -eq 1 ]; then
echo "$GIT_VERSION_TAG" GIT_VERSION_HASH=$(cat $1/GIT_VERSION)
exit 0
fi
if [ -n "$GIT_VERSION_HASH" ]; then if [ -n "$GIT_VERSION_HASH" ]; then
echo "$GIT_VERSION_HASH" echo "$LATEST_RELEASE+git.$GIT_VERSION_HASH"
exit 0 exit 0
fi fi
fi fi
...@@ -78,7 +74,7 @@ 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) # 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 GIT_COMMIT=$(git log -1 --format=%h) && true
if [ -n "$GIT_COMMIT" ]; then if [ -n "$GIT_COMMIT" ]; then
echo "$GIT_COMMIT" echo "$LATEST_RELEASE+git.$GIT_COMMIT"
exit 0 exit 0
fi 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