mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
Fix the quoting for git local change detection. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run ./util/getversion.sh on a repository with and without local changes and observe we no longer have a spurious output on stderr. Change-Id: I40ea4505d175c9135027ba7cf2b787c08eff6f70
34 lines
1009 B
Bash
Executable File
34 lines
1009 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Generate version information for the EC binary
|
|
|
|
if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then
|
|
if gdesc=`git describe --dirty --match='v*' 2>/dev/null`; then
|
|
IFS="-" fields=($gdesc)
|
|
tag="${fields[0]}"
|
|
IFS="." vernum=($tag)
|
|
numcommits=$((${vernum[2]}+${fields[1]:-0}))
|
|
ver_major="${vernum[0]}"
|
|
ver_branch="${vernum[1]}"
|
|
else
|
|
numcommits=`git rev-list HEAD | wc -l`
|
|
ver_major="v0"
|
|
ver_branch="0"
|
|
fi
|
|
# avoid putting the -dirty attribute if only the timestamp
|
|
# changed
|
|
git status > /dev/null 2>&1
|
|
|
|
dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
|
|
ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
|
|
else
|
|
ver="no_version"
|
|
fi
|
|
echo "#define VERSION \"${ver}\""
|
|
echo "#define DATE \"`date '+%F %T'`\""
|
|
echo "#define BUILDER \"${USER}@`hostname`\""
|