diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2017-09-13 13:55:33 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-15 08:46:32 -0700 |
commit | 38650d0b5de0df77d5c3985c17ac38f9865f6cbb (patch) | |
tree | d3e944d2169a40055764e7df0912213705051ea1 /util | |
parent | b5d9913241046764855ed49450dfed51dbf309a3 (diff) | |
download | chrome-ec-38650d0b5de0df77d5c3985c17ac38f9865f6cbb.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>
Diffstat (limited to 'util')
-rwxr-xr-x | util/getversion.sh | 14 |
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 } |