summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-09-13 13:55:33 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2017-09-15 16:08:51 +0000
commit3e7d56900988c8c784e4e049189445a1ed122027 (patch)
treee12ad28029e41c985ee4d059e73a456fbc317028
parent580edf092563ba07ab46686b22636e67a37225fc (diff)
downloadchrome-ec-3e7d56900988c8c784e4e049189445a1ed122027.tar.gz
util: move 'dirty' marker to be a prefix, not a suffix
With longer git SHA1s reported by git commands and longer version strings, the entire SHA1 could be not fitting into the 32 byte version of the VERSION string. So, instead of adding the 'dirty' marker to the end of SHA1 let's replace the prefix dash with it in case the tree is dirty. This way the length of the version string does not change (as long as the 'dirty' marker is one character long). BRANCH=cr50 BUG=b:64698702 TEST=verified output of running getversion.sh with a clean tree $ ./util/getversion.sh | grep VERSION32 #define CROS_EC_VERSION32 "_v1.1.7046-591608e2e" and a 'dirty' tree $ ./util/getversion.sh | grep VERSION32 #define CROS_EC_VERSION32 "_v1.1.7046+591608e2e" Change-Id: I42684522beaff9e9714206cfaddaf97e6cd644be Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/665958 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 38650d0b5de0df77d5c3985c17ac38f9865f6cbb) Reviewed-on: https://chromium-review.googlesource.com/668698
-rwxr-xr-xutil/getversion.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/util/getversion.sh b/util/getversion.sh
index 18a6ee9ba1..660ca24baf 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -28,7 +28,7 @@ dirty_marker='+'
# "no_version"
get_tree_version() {
- local dirty
+ local marker
local ghash
local numcommits
local tag
@@ -54,9 +54,11 @@ get_tree_version() {
git status > /dev/null 2>&1
if [ -n "$(git diff-index --name-only HEAD 2>/dev/null)" ]; then
- dirty="${dirty_marker}"
+ marker="${dirty_marker}"
+ else
+ marker="-"
fi
- vbase="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
+ vbase="${ver_major}.${ver_branch}.${numcommits}${marker}${ghash}"
else
# Fall back to the VCSID provided by the packaging system if available.
if ghash=${VCSID##*-}; then
@@ -66,7 +68,11 @@ get_tree_version() {
vbase="no_version"
fi
fi
- echo "${vbase}${dc}${dirty}"
+ if [[ "${marker}" == "${dirty_marker}" ]]; then
+ echo "${vbase}${dc}${marker}"
+ else
+ echo "${vbase}${dc}"
+ fi
}